Loading...
AppServer is a tiny (432Kb), portable, web server that helps you build client-side HTML applications by providing basic file system access to the web-pages it serves.
It's main advantage over frameworks like Node.js is it's size. The AppServer.exe file is only 432Kb and it's the only file you need to run your HTML apps. This small footprint makes distribution a breeze. Put your files and folders in a parent folder along with the AppServer.exe and your're good to go. Users launch the AppServer.exe and the rest happens automatically.
When AppServer starts, it looks for "app.html" in its own directory. This is the "entry point" for apps. AppServer will open app.html in the default browser. It runs on the localhost. So URLs look like this: "localhost:5000/app.html"
Feel free to rename the executable to match the application you're building. The first time you run it, Windows FireWall security may ask you to allow the Program to run. Click "Allow" and the message won't appear again.
AppServer.exe is published under the MIT License. Links to the license and the compiled, portable binary (.exe) for Windows can be found in the download section.
Copyright (c) 2016 Spencer A. Jobe
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AppServer.exe is published under the MIT License. It is a portable executable that runs natively in Windows. The portable 32-bit Windows binary and an example app are available for download below. Linux, and MacOS versions will be available in the future.
Category: Summary Files Folders Storage Http Paths
Select a category above
Summary
AppServer provides a small set of JavaScript functions that let you access the underlying file-system, store persistant data, and send standard GET and POST requests to other servers. Functions are detailed by category. The categories are listed above. Click on each for more information. To use these commands, you must include a reference to the System.js file in your HTML files as seen below.
<script src="System.js"><script>
The System.js file is stored inside the AppServer itself, so you don't have to worry about keeping track of files. This also insures that the proper file is delivered: you can't accidently "mask" the file by including it in your app folder.
All of the AppServer functions reside in global object "System". Each function has a corresponding asynchronous function that takes an additional callback parameter. Async functions are nested in the System object under "Async" (ie System.Async) See example below.
System.readAllText("/some_folder/file.txt");
System.Async.readAllText("/some_folder/file.txt", callbackFunction);
Here, System.readAllText will return the contents of the file, while System.Async.readAllText will pass the contents of the file to the callback function once AppServer has read the file. For more information on File commands, see the "Files" category. For infomation on Folder commands, see the "Folders" category.
AppServer provides several functions that allow you to get and set text values in the memory space of the AppServer itself. These functions behave like HTML's LocalStorage but are actually stored in the AppServer. There is also a long-term storage option that stores the text in a file within the "storage" folder in the AppServer's root directory. These value are saved until they are deleted. For more information see the "Storage" category.
AppServer provides functions that make it easy to send GET and POST request to other servers. This can be helpful when you want to link your application to a server or web-service. For more information see the "Http" category.
AppServer differentates between full and relative paths. For more information on how AppServer handles Paths, see the "Paths" category.
File Commands |
|
Folder Commands |
|
Storage Commands |
|
This function returns a string representing the contents of the file specified by the path.
This function returns an array where each element contains one line of the file specified by the path.
This function writes the provided contents to the file specified by the path.
This function writes a file specified by the provided path where each element of the array is treated as one line of the file.
This function copies the file at the source path location (srcPath) to the destination path (destPath).
This function moves the file at the source path location (srcPath) to the destination path (destPath).
This function deletes the file at the specified path.
This function returns true if the file exists and false if the file does not exist or could not be accessed.
This function returns the size of the file in bytes. This function returns -1 if the file does not exist or could not be accessed.
This function creates a folder at the specified path.
This function copies the folder at the source path location (srcPath) to the destination path (destPath). The folder and it's contents are copied.
This function moves the folder at the source path location (srcPath) to the destination path (destPath). The folder and it's contents are moved.
This function deletes the folder and its contents at the specified path.
This function returns true if the folder exists and false if the folder does not exist or could not be accessed.
This function returns an object with two properties: files, and folders. The files property contains an array of full file paths to each file within the folder. The folders property contains an array of full sub-folder paths to each sub-folder within the the folder specified by the path.
NOTE: This function does a "shallow" dredge of the specified folder. So if the specified folder contains subfolders, the contents of those subfolders is NOT contained in the results.
This function stores a name / value pair that can be accessed by any page running on the App Server. This storage is persistant until the App Server closes. This is NOT the browser's local storage. It is managed by the App Server. Values can also be deleted using the deleteValue command.
This function returns a value stored under the provided name, or returns "undefined" if the value is not present. This storage is persistant until the App Server closes. This is NOT the browser's local storage. It is managed by the App Server. Values can also be deleted using the deleteValue command.
This function deletes the name / value pair stored under the provided name in the AppServer session. This storage is persistant until the App Server closes or this command deletes the value. This is NOT the browser's local storage. It is managed by the App Server.
This function stores a name / value pair that can be accessed by any page running on the App Server. These values are stored on the file system in the same directory as the AppServer.exe in a folder called "storage". Files within this folder are stored as "[name].store" where [name] is the provided name. This is NOT the browser's local storage. It is managed by the App Server. These values persist on the hard-drive until they are deleted. Storage values can be deleted with the deleteStorage command.
This function returns a value stored in the storage directory under the provided name, or returns "undefined" if the storage file is not present. These values are stored on the file system in the same directory as the AppServer.exe in a folder called "storage". Files within this folder are stored as "[name].store" where [name] is the provided name. This is NOT the browser's local storage. It is managed by the App Server. These values persist on the hard-drive until they are deleted. Storage values can be deleted with the deleteStorage command.
This function deletes the name / value pair stored in the storage directory. These values are stored on the file system in the same directory as the AppServer.exe in a folder called "storage". Files within this folder are stored as "[name].store" where [name] is the provided name. This is NOT the browser's local storage. It is managed by the App Server. These values persist on the hard-drive until they are deleted manually, or by using this function.
This function sends a standard HTTP GET request based on the provided url, waits for a response, then returns the responseText. Use the Async version below if you do not want to wait for the server to respond. GET args can be specified after the url. For Example:
var resp = System.httpGet("http://somesite.com/foo.php?a=test&b=something else")
This function sends a standard HTTP POST request based on the provided url and optional postString, waits for a response, then returns the responseText. Use the Async version below if you do not want to wait for the server to respond. GET args can be specified at the end of the url. However, POST args are passed in as a seperate string in the second parameter. AppServer does not handle binary POST data. All POST args must be passed as a string.
The App Server handles both full and relative paths. Any function in System.js that takes a path as input can take a full path, relative path, or network path.
These are paths that start in the same directory where AppServer.exe resides. So, if the AppServer.exe is sitting in "C:/web_stuff/app/", and you called:
System.readAllText("example.txt");
the path would be translated to "C:/web_stuff/app/example.txt". This makes it easy to drop files into the "C:/web_stuff/app/" folder and reference them in your code using the relative path.
These are paths that use a drive letter as a reference. For example "C:/web_stuff/app/example.txt" is a "drive-letter" path. If you need to access a file that is NOT in app folder, you can specify the entire path.
These are paths that specify a network share using the "\\" prefix. For example, "\\fileserver1\web_stuff\app\". these paths are valid assuming you have connectivity.