Create TCP and HTTP servers with the Haxe programming language, or run haxelib run snake-server
to start a local HTTP server that serves static files in a specific directory.
Warning! snake-server is not recommended for production. It only implements basic security checks.
Available on Haxe sys targets only.
Use the haxelib install command to download Snake Server.
haxelib install snake-server
Requires Haxe 4.1 or newer.
Use the haxelib run command to launch Snake Server in the current directory on port 8000.
haxelib run snake-server
The following options can be added to the haxelib run snake-server command to customize its behavior.
-
--bind address
bind to this address (default: 127.0.0.1)
-
--directory path/to/dir
serve this directory (default: current directory)
-
--protocol HTTP/X.Y
conform to this HTTP version (default: HTTP/1.0)
-
--port number
bind to this port (default: 8000)
-
--cors
add headers to enable CORS (Cross-Origin Resource Sharing)
-
--no-cache
add headers to disable caching in web browsers
-
--silent
disable logging of requests
-
--open-browser
launches the server's URL in a web browser
-
--help
print usage instructions
Example:
haxelib run snake-server --bind 0.0.0.0 --port 3000 --protocol HTTP/1.1 --directory www
The Snake Server project's Haxe code is actually ported from the Python language's http.server and socketserver modules. Pythons are also a type of snake. The name is simply meant to pay tribute to the code's origins.