This is CS50
http-server
https://www.example.com/
https://www.example.com/file.html
https://www.example.com/folder/
https://www.example.com/folder/file.html
https://www.example.com/path
https://www.example.com/route
https://www.example.com/route?key=value
https://www.example.com/route?key=value&key=value
GET /search?q=cats HTTP/2
Host: www.google.com
...
Flask
flask run
app.py
requirements.txt
static/
templates/
app.py
requirements.txt
static/
templates/
from flask import Flask, render_template
app = Flask(__name__)
@app.route("/")
def index():
return render_template("index.html")
request.args
Jinja
request.form
Controller
View
Controller
View
Model
GET / HTTP/2
Host: accounts.google.com
...
HTTP/2 200
Content-Type: text/html
...
HTTP/2 200
Content-Type: text/html
Set-Cookie: session=value
...
GET / HTTP/2
Host: accounts.google.com
...
GET / HTTP/2
Host: accounts.google.com
Cookie: session=value
...
session
from cs50 import SQL
[
{"id": 1, "title": "The Hitchhiker's Guide to the Galaxy"},
{"id": 2, "title": "The Restaurant at the End of the Universe"},
{"id": 3, "title": "Life, the Universe and Everything"},
{"id": 4, "title": "So Long, and Thanks for All the Fish"},
{"id": 5, "title": "Mostly Harmless"},
]
API
[
{"id": 112108, "title": "The Office", "year": 1995, "episodes": 6},
{"id": 290978, "title": "The Office", "year": 2001, "episodes": 14},
{"id": 386676, "title": "The Office", "year": 2005, "episodes": 188},
{"id": 1791001, "title": "The Office", "year": 2010, "episodes": 30},
{"id": 2186395, "title": "The Office", "year": 2012, "episodes": 8},
{"id": 8305218, "title": "The Office", "year": 2019, "episodes": 28},
{"id": 20877972, "title": "The Office", "year": 2022, "episodes": 20},
]
JSON
[
{"id": 112108, "title": "The Office", "year": 1995, "episodes": 6},
{"id": 290978, "title": "The Office", "year": 2001, "episodes": 14},
{"id": 386676, "title": "The Office", "year": 2005, "episodes": 188},
{"id": 1791001, "title": "The Office", "year": 2010, "episodes": 30},
{"id": 2186395, "title": "The Office", "year": 2012, "episodes": 8},
{"id": 8305218, "title": "The Office", "year": 2019, "episodes": 28},
{"id": 20877972, "title": "The Office", "year": 2022, "episodes": 20}
]