If you have a working Flask app that you can run on localhost on your computer, you can easily make it public by deploying it on PythonAnywhere. It takes a couple of minutes to deploy. Here are the steps how to do it:
- Make sure you have signed up for a free PythonAnywhere account and you’re logged in.
- Go to the Web menu item and then press the Add new web app button.
- Click Next, then click on Flask and click on the latest version of Python that you see there and then click Next again to accept the project path.
That’s it. You can visit your web app on https://yourusername.pythonanywhere.com. (change username with your actual PythonAnywhere username). That’s the URL of your app. You will see something like “Hello from Flask” there. If you want to upload your own project, please follow the next steps:
4. In the Code section of the Web menu page click on Go to Directory next to Source Code.
5. Delete the flask_app.py file.
6. In your local computer rename your main Python file to flask_app.py. PythonAnywhere will be looking for such a file name.
7. Use the Upload a file button to upload your own flask_app.py Python file.
8. If you have html, css and other project files, you can create a templates and a static directory in the Directories section and upload your files there.
9. Go to the Web menu page and click on the Reload button.
Now your Flask app should be app and running on https://yourusername.pythonanywhere.com. On the free plan you have 500 MB of disk space so if your project gets bigger you may want to upgrade for one of the PythonAnywhere paid plans.
If you want to learn how to use the PythonAnywhere terminal to navigate to the server, create and execute Python programs, please see How to use PythonAnywhere. If you want to learn how to build complete Flask applications with a database backend, and HTML, and CSS frontend you can sign up for my course The Python Mega Course: Build 10 Real World Applications.