-
Notifications
You must be signed in to change notification settings - Fork 1k
Run a CGI script or host static HTML
You can combine standard and CGI scripts using websocketd server. You also could serve static HTML files with it. It's not advisable since other HTTP servers are much more advanced but sometimes it's good way to host something with minimal effort.
When server reads startup flags it'll create endpoints based on file names inside of mapped folders. For example if your tree is:
/app/docs
app.html
image.jpg
/app/cgi
hello.py
/app/ws
count.py
This command:
websocketd --address=host --port=8000 --staticdir=docs --cgidir=cgi --dir ws
will start websocketd in a way that it would serve websocket counter at http://localhost:8000/count.py and CGI hello at http://host:8000/hello.py. Files from /docs would be served under their names.
All other websocketd options are compatible with --cgidir
and --staticdir
except --devconsole
. Note that index.html is not discoverable by default and you would need to use some special HTTP frontend to do so.
You also could use a single websocket script to map all URLs that not answerable by CGI or STATIC dir.
... --staticdir=docs --cgidir=cgi ws/count.py
would do that for you.
Currently you could not use --dir
and "catchall" script.
The websocketd user guide is a publicly editable wiki. Please contribute!
Getting Started
Reference
Language specific
Advanced: Internals
Spanish Websocket Wiki
Primeros pasos
Referencia
Lenguajes
Avanzado