Coding in Python 24 – Serving an HTML Site with Flask

YouTube player

Code used in this Video

Setting up the environment

virtualenv -p /usr/bin/python3 my-project
cd my-project
source bin/activate
pip install Flask

Running a simple web page

#!/usr/bin/env python3

from flask import Flask
app = Flask(__name__)


@app.route("/")
def message():
    return "Python is awesome!"


app.run()
==== Flask with debug option ====
#!/usr/bin/env python3

from flask import Flask
app = Flask(__name__)


@app.route("/")
def message():
    return "Python is awesome!"


app.run(debug=True)

Brand-New Course!

Support Linux Learning and get yourself some cool Linux swag!

Check out the Shop!

Support Linux Learning and get yourself some cool Linux swag!

Support Linux Learning

Consider becoming a Patron and/or Channel Member to receive exclusive perks!


Receive 5% off an LPI exam voucher!