Deploy Flask

This article will teach you how to deploy your Flask project on Zeabur.

Step1: Create Flask Project

You can get the example project from flask-template. The Flask example is quite simple. It has a single route that returns a string.

from flask import Flask
import os
 
app = Flask(__name__)
 
@app.route('/')
def index():
    return "Welcome, this is a Flask app deployed on Zeabur"
 
if __name__ == '__main__':
    app.run(debug=True, port=os.getenv("PORT", default=5000), host='0.0.0.0')

Please note that Zeabur uses environment variable PORT to determine which port to forward. You will therefore need to set this environment variable and use os.getenv or other ways to configure the port number in your application.

Zeabur uses python app.py or python main.py to run Python App. So Your project should contain one of these files and include the commands needed to run the Flask application.

Zeabur determines which ports to open based on the environment variable PORT.

Step2: Deploy

Click on Add new service button, then choose Deploy your source code.

deploy

Search for your Flask App repository, click on import, your Flask App will start deploying.

Note that Zeabur uses Gunicorn as the WSGI production server for running Flask services.