Using cookiecutter to create simple hosted aiohttp web application
Overview
We will be using cookiecutter package to quickly spin up a simple web application using next stack: Python 3 + aiohttp + npm + Heroku. The main advantages of this approach is to have working and deployed application in couple of minutes. The only thing left is to update your business logic on back-end and to rearrange components on your html pages using one of the simplest css frameworks (siimple).
Prerequisites
If you do not have those yet make sure all of the dependencies are installed first
1 | $ pip install pipenv |
That should be enough to start.
So easy?
Clone preexisting boilerplate code from github and answer couple of questions about your future project and you’ll be good to go. Let’s assume that our project name is myapp
.
1 | $ git clone git@github.com:bmwant/templio.git |
Check and verify that our project works locally and everything is in place by launching it
1 | $ pipenv shell |
Now visit 127.0.0.1:8081
in your browser and that’s it.
Deployment
It’s time to make our site available for others via free hosting on Heroku.
Create new application here and type commands below
1 | $ heroku login # just one to sign into your account |
Now you can access your web application at https://myapp.herokuapp.com/
and share that link with others!
Your regular developing workflow would look like this:
- Make some changes locally (e.g. add new endpoints/templates)
- Test modifications locally (via
python runserver.py
) - Commit changes to git repository
- Deploy changes to remote (
git push heroku master
)
Basically, it’s everything you need to now at this point to have a ready-to-go web application. You can fork templio
project and edit it according to your taste making it easier to create new projects from a scratch a lot faster than before.