Skip to content

webdemo1.py

Hector Correa edited this page Jan 2, 2024 · 2 revisions

Python / Flask

Create a virtual environment:

$ mkdir myproject
$ cd myproject
$ python3 -m venv .venv

$ source .venv/bin/activate

$ pip install Flask

Create a file called webdemo1.py with the following content:

from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello_world():
    return "<p>Hello, World!</p>"

Run the Flask app:

FLASK_APP=webdemo1 flask run

Sources

https://www.digitalocean.com/community/tutorials/how-to-make-a-web-application-using-flask-in-python-3

https://flask.palletsprojects.com/en/3.0.x/quickstart/#

https://flask.palletsprojects.com/en/3.0.x/installation/

Clone this wiki locally