Url Server
By Tgwizman
I made this library to make it easier on myself to prototype web servers. I ended up writting a framework around this, so this is slowly getting pushed into a solid "product". This is what I have to offer.
Simple Usage
Hosting a server using HTTP
var ur = ; ur; ur;
Hosting a server using HTTPS
var ur = ; ur; ur;
Some Uses
Params, Post
Url parameters are separated from the url path and put into the input. Http post requests are waited on to get post body parameter string key value pairs and are also put into the input.
ur;
Redirecting
If you need to redirect the user to a different page, it is so simple.
ur;
File Receiving
Receiving a file is super simple. Just make an on load listener, and get the data when it's ready.
ur;
Data Storage
Use files as data storages, and forget the hard parts. Load a database by path, and if it doesn't exist, it will be automatically created and loaded. When you save a database, you just reference it again by the path, and all the data will be saved.
var users = ur; users'Tgwizman' = favoriteColor: '#369C'; ur;
File 'db/users.json':
"Tgwizman": "favoriteColor": "#369C"
Other Uses
Logging
Keeping track of times and dates can be very important!
ur;// output:// '[06/13/2019 02:31:04] Blah. Some text.'
Files
Accessing files can be a nuisance. These methods should make everything pretty straight forward.
// get file// returns file textvar str = ur; // get file raw// returns file without forcing utf8var file = ur; // set file// sets file textur; // get JSON file// returns json object from file textvar obj = ur; // set JSON file// saves json object as text to fileur; // deletes fileur; // deletes folder// [WARN!] will recursively delete contents by default without warningur; // rename itemur; // make folder// parent folders must already existur; // check if file existsvar bool = ur; // get the mime type of a filevar str = ur;// returns 'text/plain' // check if file name is windows friendlyvar bool = ur;
Miscellaneous
Anything that doesn't fall into one of the categories above is going to be tossed here for now.
// Get network addressesvar network = ur; "hostname": "MyComputerName" "networkInterfaces": "wifi": "mac": "4567:89AB:CDEF" "addresses": "192.168.0.5" "loopback": "mac": "0123:4567:89AB" "addresses": "127.0.0.1" // Get date and time with formatvar date_str = ur // '06/13/2019' time_str = ur; // '02:31:04' // HTTP GETur.httpGet(url, options, callback)// HTTPS GETur.httpsGet(url, options, callback)// HTTP PUTur.httpPut(options, body, callback)
Requests
If you would like to see anything added or anything changed, contact me.
Errors
I have made this for myself. If you are going to be using this, please know that there are many bugs and errors will happen. If you come across any, please let me know and I will try to fix them as soon as I can.