http-server
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
GET /search?q=cats HTTP/2
Host: [Link]
...
Flask
flask run
[Link]
[Link]
from flask import Flask
app = Flask(__name__)
@[Link]("/")
def index():
return "hello, world"
[Link]
[Link]
static/
templates/
from flask import Flask, render_template
app = Flask(__name__)
@[Link]("/")
def index():
return render_template("[Link]")
[Link]
Jinja
[Link]
[Link]/templates/
Controller View
Model Controller View
POST / HTTP/2
Host: [Link]
...
HTTP/2 200
Content-Type: text/html
...
HTTP/2 200
Content-Type: text/html
Set-Cookie: session=value
...
GET / HTTP/2
Host: [Link]
...
GET / HTTP/2
Host: [Link]
Cookie: session=value
...
session
from cs50 import SQL
API
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}
]