How to Build a Simple Flask Web App
Flask is a lightweight Python web framework. This guide builds a minimal app inside a virtual environment.
1. Set up the environment
mkdir flaskapp && cd flaskapp
python3 -m venv venv
source venv/bin/activate
pip install flask2. Create the app
# app.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def home():
return 'Hello from Cloudesta!'
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)3. Run it
python app.pyVisit http://your-server-ip:5000 to see it.
4. Production note
Don’t use the built-in server in production. Use Gunicorn behind Nginx:
pip install gunicorn
gunicorn -w 4 -b 127.0.0.1:5000 app:appThen reverse-proxy to it with Nginx.