hn.today

The Flask Mega-Tutorial, Part I: Hello, World

blog.miguelgrinberg.com4 points0 comments
Screenshot of The Flask Mega-Tutorial, Part I: Hello, World

Part I of the 2024 Flask Mega-Tutorial walks through the very first steps to get a Flask web application running locally and serves as the foundation for a 23‑chapter course. It points to GitHub-hosted example code (with browse/zip/diff links for each chapter) and encourages typing examples to learn. The chapter covers installing Python if needed, verifying the interpreter, and the recommended workflow of using per-project virtual environments to avoid dependency conflicts. It explains why pip should be used inside a venv, how to create and activate a virtual environment across Linux/Mac/Windows/PowerShell, and how to install Flask (defaulting to the latest 3.x while giving commands to stay on 2.x if desired). A quick check with import flask confirms installation.

The chapter then builds a minimal but structured “hello world” application: create a microblog project directory, add an app package, and write an __init__.py that instantiates the Flask application with app = Flask(__name__) and imports routes. It explains the distinction between the app package (the directory) and the app Flask instance (the variable), and notes that using __name__ helps Flask locate resources like templates. These steps provide a practical, reproducible starting point for following the rest of the tutorial series.

Read on blog.miguelgrinberg.com0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.