←Tutte le torri

Raahaao Code: Flask

Crea siti web e API Python reali con Flask.

9+ ore di lezioni · 2 progetti · €35

Ti aiuta a prepararti per: PCAP – Certified Associate Python Programmer (Python Institute)

Oppure includila in un piano mensile da €3.46 a settimana (addebitati €15 al mese) →

Serve un account per aprire qualsiasi lezione. Senza account puoi sfogliare le torri e i prezzi.

Paga in

Cosa imparerai, piano per piano

  1. 1

    First app (Beginner)

    • How a web framework works
    • Routes and views
    • Templates with Jinja
  2. 2

    Forms & data (Beginner)

    • Request data
    • Validation and flash messages
    • Static files and layout
  3. 3

    Storage (Intermediate)

    • SQLite from Flask
    • CRUD pages
    • Blueprints and app factories
  4. 4

    Users (Intermediate)

    • Sessions and cookies
    • Logins with hashed passwords
    • Authorisation: roles and ownership
  5. 5

    Pro (Job-ready)

    • JSON APIs
    • Security essentials
    • Testing a Flask app
    • Deploying Flask

I due progetti sul tetto

Link-in-bio builder

Build a small Flask service where people can register, sign in, and maintain a public profile with useful links. The app uses SQLite for accounts and profile data, a signed session to remember the current user, and password hashes instead of readable passwords.

  • create_app(test_config=None) returns a configured Flask application and accepts per-app configuration, including DATABASE and SECRET_KEY
  • POST /register accepts JSON username and password, creates a user and empty profile, returns {"username": username} with 201, returns 400 for invalid input, and 409 for a duplicate username
  • POST /login verifies a username and password, returns {"username": username} with 200 and stores the user id in the session; invalid credentials return {"error": "Invalid username or password"} with 401; POST /logout clears the session and returns {"message": "Logged out"} with 200; passwords are stored as Werkzeug hashes
  • PUT /api/me requires login and accepts JSON display_name, bio, and links; display_name must be 1–80 characters, bio at most 160 characters, and links a list of at most 5 absolute http or https URLs; valid data is saved and returned with 200, invalid data returns a JSON error with 400, and anonymous requests return 401
  • GET /u/<username> returns an HTML public profile page with display name, bio, and links; user-provided text is HTML-escaped and an unknown username returns {"error": "Profile not found"} with 404
  • Profile edits are limited to the authenticated owner; unauthenticated edit requests return {"error": "Login required"} with 401
  • GET /api/u/<username> returns {"username": username, "display_name": display_name, "bio": bio, "links": links} with 200, or {"error": "Profile not found"} with 404

Class booking system

Build a Flask app for a small class studio, where customers can book a place and cancel their own booking. An admin can create classes with a time and capacity, and clients can inspect the schedule through a JSON API.

  • create_app(config=None) returns a fresh Flask application and applies configuration overrides.
  • The app stores classes and bookings in SQLite, using parameterized SQL and the configured DATABASE path.
  • Only a session with role "admin" can create a class.
  • GET /api/classes returns 200 JSON with the shape {"classes": [...]} and each class has id, name, starts_at, capacity, and booked.
  • A customer can book an available class with POST /api/classes/<int:class_id>/book, receiving 201 JSON {"booking_id": id, "class_id": class_id}.
  • A customer cannot book the same class twice; the repeated request returns 409 JSON {"error": "already booked"}.
  • A class cannot be overbooked; a booking when it is full returns 409 JSON {"error": "class is full"}.
  • A customer can cancel their own booking with DELETE /api/bookings/<int:booking_id>, receiving 200 JSON {"cancelled": true}.
  • A customer cannot cancel another customer’s booking; the response is 404 JSON {"error": "booking not found"}.
  • Booking a class that does not exist returns 404 JSON {"error": "class not found"}.
  • Invalid class input returns 400 JSON {"error": "name and starts_at are required; capacity must be a positive integer"}.
  • Unauthenticated booking requests return 401 JSON {"error": "login required"}; non-admin class creation returns 403 JSON {"error": "admin required"}.
  • The learner writes at least five test_ functions in app.py and runs each one with Flask’s test client.

Domande

Devo installare qualcosa?

No. Tutto funziona nel tuo browser. Per i progetti puoi anche lavorare sul tuo computer e caricare i tuoi file.

Posso saltare quello che conosco già?

Sì. Una volta che possiedi una torre, ogni piano ha un test di salto: segna 8 su 10 e quel piano si apre.

Qual è la politica di restituzione?

Rimborsi entro 5 giorni dall'acquisto. Dopo 5 giorni, nessun rimborso o reso.

Mantengo l'accesso?

Sì. Una torre che acquisti è tua, senza abbonamento.

Refund policy