How To Host Your Flask App For Free!

Today we will go over how one can deploy their Flask app with PythonAnywhere .


Click learn more to discoveirng more information about WebSanctuary.

Learn more

1) Required Tools

Tools Needed:

1) A functional Flask Application

2) An account with PythonAnywhere


2) Overview of Flask App

The Flask Application That Will Be Hosted

(flask_app/templates/index.html) HTML Code:

<!DOCTYPE html>
<html>
<head>
<title> Flask App Tutorial </title>
</head>
<body>
<h1>Flask App Tutorial</h1>
</body>
</html>

(flask_app/app.py) Python Code:

from flask import Flask, render_template

app = Flask(__name__)

@app.route('/')
def index():
  return render_template('index.html')

if __name__ == "__main__":
    app.run(debug=False)

End Result:

Final Result Website

3) Create a Webapp on PythonAnywhere

After creating your account, go to the "Web" tab.

How to host your Flask website for free.

Then create your new webapp!

How to host your Flask website for free.

You will then be prompted to create a web app. Please follow the directions carefuly.


After this, navigate to the files tab. You will notice that you see a flask_app.py file. Delte this file and then upload your own file Python file.

How to host your Flask website for free. How to host your Flask website for free.

4) Upload HTML File(s)

Navigate back to the files section. The GUI on the left will show a folder called "my site". Navigate into this directory. Click the mysite directory.

How to host your Flask website for free.
How to host your Flask website for free.

Now that you are inside the "my-site" folder, you are now able to create files inside this folder. To complete the next step, you must create a folder called templates and inside that folder upload the HTMl files that you require.

How to host your Flask website for free.
How to host your Flask website for free.

Once navigated/clicked into the templates file you will be able to upload your HTML files.

How to host your Flask website for free.
How to host your Flask website for free.

5) Configure the WSGI Configuration File

Navigate to the Web Tab and scroll down. View the image below to navigate to the WSGI Configuration file.

How to host your Flask website for free.

Once you have clicked on the file, you will be prompted to edit the file. When editing, change "flask_app" to the name of your Python file. In this case, we will be changing it to "app" because our Python file is "app.py".

How to host your Flask website for free.

The underlined word is the word that should be changed from flask_app to the name of your Python application. If your python application is 'app.py', you must input 'app' in place of 'flask_app'.


6) Admire Your Work!

Congratulations, your app is being hosted with PythonAnywhere! The URL that you have been given now leads to your website.