Chapter 1: Getting Started with Modern Python Web Apps
ASP.NET Core gives you a project template, Program.cs, a dependency injection container, configuration providers, middleware, and Kestrel. In Python, you assemble those pieces more explicitly. That is empowering, but it can feel underspecified at first.
The Python version of "create a new web project" is usually:
- Create a virtual environment.
- Add dependencies to
pyproject.toml. - Create an ASGI app object.
- Run the app with a server such as Uvicorn.
- Add tests from the beginning.
Recommended starting layout:
recipevault/
pyproject.toml
src/
recipevault/
__init__.py
main.py
settings.py
api/
web/
domain/
data/
services/
tests/
src/ layout avoids accidental imports from the working directory and makes packaging behavior more honest. This is more ceremony than a small script needs, but it pays off for real applications.
Minimal app:
# src/recipevault/main.py
from fastapi import FastAPI
app = FastAPI(title="RecipeVault")
@app.get("/health")
def health() -> dict[str, str]:
return {"status": "ok"}
Run it:
uvicorn recipevault.main:app --reload
Modern Python web development rewards explicitness. You choose the application structure, dependency boundaries, test style, and persistence approach. The job of this guide is to give you a default path so every choice is not a research project.