25
loading...
This website collects cookies to deliver better user experience
mkdir flask-on-koyeb
cd flask-on-koyeb
python3 -m venv ~/.venv/flask-app
flask-app
in the ~/.venv directory. The virtualenv contains a copy of the Python interpreter, pip, the standard library, and various supporting files.source ~/.venv/flask-app/bin/activate
pip install Flask Gunicorn # Install Flask and Gunicorn
pip freeze > requirements.txt # Create the requirements.txt to store the dependencies and version of each package required to run our application.
flask-on-koyeb
directory, create a new app.py
file with the following:from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, World!'
if __name__ == "__main__":
app.run()
/
requests and return Hello, World!
as a response.python3 app.py
http://localhost:5000
and you will see Hello, World!
.git init
curl https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore > .gitignore
git add .
git commit -m "Flask app initial commit"
flask-on-koyeb
and click the Create repository button. Then, go back to your terminal and add GitHub as a remote repository by running:git remote add origin [email protected]:YOUR_GITHUB_USERNAME/flask-on-koyeb.git
git branch -M main
git push -u origin main
GitHub
as your deployment method.Main
.gunicorn app:app
for your Run command to let Koyeb know how to launch your application.koyeb-flask-demo
, and click Create App.
Note: You can add more regions, change the instance size, set environment variables, and define horizontal scaling according to your needs. |
---|