I have been enjoying HTML games recently and I use the following method to start a local server and keep it all in one place to track (As I'm lazy to update the list a python script does it on its own)
Short Version:
I run node.js local server and update the HTML files using python that automatically updates and I get a webpage with all the games in the same directory and sub-directory. You can download the files attached after following the requirements section or read the details to learn more about what's going on.
Requirements and setup:
I'm going to try to write this in as much detail as I can there are two available versions for the server (as written in the BAT file) one of which is using python the other is using node.js (which I highly recommend as it doesn't allow for caching and opens the browser as the server runs). If you want to use that follow from step 1 or skip to step 3.
1. [OPTIONAL] Install node.js and npm from the official website here:
2. [OPTIONAL] After node.js and npm are installed open a command line (WIN KEY + R > "CMD" > RUN) and enter the following command
this installs the npm package (http-server -
3. Install python 3 from the following URL:
4. Extract the contents of the ZIP package to a directory.
5. Each game should be in a sub-directory under the one made in step 4
6. [OPTIONAL] If step 1 and 2 were not followed open the server.bat file in any text editor (notepad will work) to change the default server from node.js to python and change the following:
to
7. Now start the file "Server.bat" this (if the node.js path was used) will start a local server, create a "list.json" file and open up a browser window.
8. ENJOY!
In detail:
Ok so in this section I'll cover each file and what it does ... IN A TABLE because its easier that way
Short Version:
I run node.js local server and update the HTML files using python that automatically updates and I get a webpage with all the games in the same directory and sub-directory. You can download the files attached after following the requirements section or read the details to learn more about what's going on.
Requirements and setup:
I'm going to try to write this in as much detail as I can there are two available versions for the server (as written in the BAT file) one of which is using python the other is using node.js (which I highly recommend as it doesn't allow for caching and opens the browser as the server runs). If you want to use that follow from step 1 or skip to step 3.
1. [OPTIONAL] Install node.js and npm from the official website here:
You must be registered to see the links
.2. [OPTIONAL] After node.js and npm are installed open a command line (WIN KEY + R > "CMD" > RUN) and enter the following command
You don't have permission to view the spoiler content.
Log in or register now.
You must be registered to see the links
).3. Install python 3 from the following URL:
You must be registered to see the links
(In the header click "Download" and it will show a drop-down with the download button) and make sure you check the add to path checkbox.4. Extract the contents of the ZIP package to a directory.
5. Each game should be in a sub-directory under the one made in step 4
6. [OPTIONAL] If step 1 and 2 were not followed open the server.bat file in any text editor (notepad will work) to change the default server from node.js to python and change the following:
You don't have permission to view the spoiler content.
Log in or register now.
You don't have permission to view the spoiler content.
Log in or register now.
8. ENJOY!
In detail:
Ok so in this section I'll cover each file and what it does ... IN A TABLE because its easier that way
Filename | Reason of existence | More about the file |
---|---|---|
list.py | Python file looks up in the directory and subdirectories to find HTML files that can be listed | This file runs python 3 to read the directory and subdirectories (Which can be changed or add more directories to search in if you edit the scan_dirs array it can use * to indicate all ex game-* which will look for any directory with game- in beginning) this script runs to generate the list.json (More about that below) you can read each line and read the comments (HTML files are sorted by last modified). |
list.json | Holds all the data of the HTML files found by list.py | This gets read by accessing
You must be registered to see the links
(if you're using the default port) by a Javascript in the index.html file |
index.html | The default homepage | Contains a table and calls map.js to get the list. |
map.js | Get the data in list.json and lays them out | There is no magic to it just get the list.json data and puts it out in the table |
update_list.bat | Calls list.py | That's all it does just call list.py |
server.bat | Calls update_list.bat to ensure that the list is up to date then starts http server | Depending on what you changed in step 6 this would open a node.js or a python local server both set by default to run on port 8882 meaning you can access this from the following url
You must be registered to see the links
or using your local network ip which enables you to run any of these HTML games on your phone or tablet or other computer (This can be disabled in node.js server option) |
Last edited: