This is a very simple webapp that uses the Sanic web framework. It implements a number of features (see below) but only to a hello-world level. Sanic supports concurrency by using the uvloop event loop implementation of Python3's asyncio. This means you can take advantage of async/await style code from Python 3.5+ which is a coroutine approach within a single process (rather than a multi-process approach).
See the dev.sh script which can be used to build and run in debug mode. After running the script, go to http://localhost:5000 to see the app. By default it runs in debug mode and reloads whenever source files are changed. There's also a run.sh script showing how it can be run without the reloading.
The following features are implemented to hello-world level, just to see them working:
- Reloading using Hupper for debug mode
- Based on Python3/Alpine docker image
- NamedDict and namedfrozen collections from maps
- Pickle to persist the task totals to file
- Bootstrap 4 template based on the Sticky footer navbar example.
- Loads an example docker swarm style secret via
/run/secrets/EXAMPLE_SECRET
. In a real project it would not be checked into the repository as this example is! See .secrets/EXAMPLE_SECRET - Jinja2 to render the main page and the two JSON endpoints (see http://localhost:5000/tasks and http://localhost:5000/totals)