Skip to content

Create TCP/HTTP servers in Haxe, or start a simple HTTP server from the command line ๐Ÿ

License

Notifications You must be signed in to change notification settings

BowlerHatLLC/snake-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

49 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Snake Server for Haxe

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.

Installation

Use the haxelib install command to download Snake Server.

haxelib install snake-server

Requires Haxe 4.1 or newer.

Command Line

Use the haxelib run command to launch Snake Server in the current directory on port 8000.

haxelib run snake-server

Options

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

Haxe Documentation

Why did you choose "snake" for the name? ๐Ÿ

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.