asyncio
-based dummy implementation of simple web server.
Some kind of travesty on sanic project, but the name of this repo speaks to itself.
This task is done due to HighLoad course 1st homework.
There are several ways to do it.
Before build Provide directory with static files and config file (by default httpd.conf
from this repo is used).
Notice That to work correct in Docker host MUST be 0.0.0.0
and port MUST be 80
!
Example command suite:
docker build -t ssanic https://github.com/jpyatachkov/ssanic.git
docker run -p 80:80 -v ~/documents:/var/www/documents:ro -v ~/httpd.conf:/etc/httpd.conf:ro --name ssanic ssanic
pip install git+https://github.com/jpyatachkov/ssanic.git
After executing this command you will be able to run ssanic
from
current python interpreter. This command is alias for ssanic.__main__
, so see next
section for CLI arguments interface details.
ssanic.__main__
is main file of Ssanic - it handles master process,
reads configuration and forks Ssanic worker processes. It has particular CLI interface:
usage: __main__.py [-h] [--document_root DOCUMENT_ROOT] [--host HOST]
[--port PORT] [--num-workers NUM_WORKERS]
[--config-file CONFIG_FILE]
optional arguments:
-h, --help show this help message and exit
--document_root DOCUMENT_ROOT
directory to serve static files from
--host HOST host to bind to
--port PORT port to listen to
--num-workers NUM_WORKERS
number of workers
--config-file CONFIG_FILE
path to config file (if provided, all other CLI args will be
ignored - their values would be obtained from config file)
ssanic.worker
is single worker. If you don't want to deal with several workers,
just run this file. It does not have any CLI interface, so you are to configure it
(just host
, port
and document_root
) through source code.