A programming quiz with WATs
A programming quiz with regular questions mixed with (much harder) questions on suprising behaviors of some languages.
This is a demo application to support this blog post.
I wanted to build a real-world application to show how docker-compose works with a backend, frontend and database.
This app lets people answer a programming quiz:
- The frontend is written with Vuejs.
- The backend is in Flask (Python) and uses a PostgreSQL database.
- We use the database to store the questions and the answers that were submitted if the user decides to record his score.
For an application this simple you could probably have used a cloud database like firebase (or no database at all!).
About the code
The point was to show a working application developed with a docker setup.
The code is probably not something you want to take as a reference.
I believe that understanding some weird behaviors of your favorite language can make you improve as a programmer.
Which does not mean that good programmers know them nor that you have to know them to be a good programmer.
- This is a nice talk that explains some Python WATs that I included in the quiz, and more Python behaviors.
- An aws/google cloud/digital ocean account with programmatic access configured on your machine.
An easy option to deploy is
You'll need to install it first. I recommend installing the bash completion and prompt as well. https://docs.docker.com/machine/install-machine/
docker-machine create --driver amazonec2 --amazonec2-open-port 80 aws-sandbox
You can swap the driver for your favorite cloud provider.
Here docker-machine will provision an ubuntu ec2 instance for us and install docker on it.
Then we run:
eval $(docker-machine env aws-sandbox)
and from now on (in our current shell), all docker commands we run will point to the ec2 instance.
# build still works as if you ran it locally, but the images are created on the remote instance. docker-compose -f docker-compose.yml -f docker-compose.prod.yml build docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d # Optional: Deactivate the docker-machine environment eval $(docker-machine env -u)
docker-machine ip aws-sandbox docker-machine ssh aws-sandbox