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!

Check out Jay’s new course on Ansible and start automating today!

Discount Vouchers


Receive 5% off an LPI exam voucher!

Exclusive Member Features

Support the channel and receive exclusive perks!