If you want to build a web server with Python Flask, here is a simple setup for Ubuntu.
1. Install Python and Flask
sudo apt update sudo apt install python3 python3-pip python3-venv -y
Create a project:
mkdir ~/flask-app cd ~/flask-app python3 -m venv venv source venv/bin/activate pip install flask
2. Create app.py
from flask import Flaskapp = Flask(__name__)@app.route("/")def home(): return """ <h1>Flask Web Server</h1> <p>Server is running successfully.</p> """@app.route("/hello/<name>")def hello(name): return f"<h1>Hello, {name}!</h1>"if __name__ == "__main__": app.run(host="0.0.0.0", port=5000, debug=True)
3. Run the server
python3 app.py
You should see something similar to:
* Running on http://127.0.0.1:5000 * Running on http://192.168.x.x:5000
Open:
http://localhost:5000
or from another computer on the LAN:
http://SERVER_IP:5000