A Python web app is only useful when other people can reach it. Deployment is the step that puts it on a server. This guide covers the basic steps for a beginner project.
Before you deploy
- Put the code in Git, and keep secrets such as passwords out of the code.
- List the packages in requirements.txt.
- Test the app on your own computer with the settings you will use on the server.
The basic steps
- Choose a host, and create a small server or a platform app.
- Copy the code and install the packages in a virtual environment.
- Set the environment variables for secrets and the database address.
- Run the app with a production server, not the development server.
- Check the logs, and open the app in a browser.
Common mistakes
- Leaving debug mode on in production.
- Storing the database password in the code.
- Forgetting to update requirements.txt after adding a package.
Next step: see our Python Full Stack course, which covers deployment in its projects at ScholarLogic, or book a free demo class. A counsellor will share the fee and the next batch dates.
