CS1999

Intense intro to webservers

Foundation CompSci project

You all know some of this already

what a webserver does
the Hypertext Transfer Protocol
how Flask fits in

1

webserver

request → response

example page load

an HTML page contains other resources
resulting in multiple requests
HTTP 200 example

Requests and responses

headers — meta information
payload — what they are actually sending
that's it

OK, it's more complicated than that

DNS and virtual servers
caching, sessions, storage
security, authentication, abuse

what if page is not there?

requests can't always be served
the servers says no
HTTP 404 example

2

HTTP

All computers on the web agree

it's a protocol
the Hypertext Transfer Protocol
of interest to you: status codes and methods

Request

do what (the method)
to what (the URL)

You know how this works?

No More Kings Sweep the Leg

So here's what you put in your request

So here's what you put in your request

So here's what you put in your request

All you do with pizza is GET

Clients can choose *methods*

GET is common... but there are others.
Let's have a look!

METHODS

HTTP specifies a METHOD indicating the nature of the request (unofficially, "the verb"):

HTTP method to
retrieve data

GET

This is the one you probably use most.

HTTP method to
retrieve no data

HEAD

GET without the body payload.

You'd do this to see if the pizza delivery network works before investing in an order.

HTTP method to
send data to process

POST

This is the one you've probably used every time you pressed SUBMIT on a form.

You don't do this unless you send ingredients to Dominoes to put on your pizza.

HTTP method to
send data to store

PUT

"Hello Dominoes? Could you look after this pizza for me? Ta."

HTTP method to
delete

DELETE

"Hello Dominoes? Cancel that I've got a burger instead."

HTTP method to
send data for modifying

PATCH

Updating pizza... I think this analogy has run its course...

Browser URL bar

Right, knowing that, you can see the first half of what a browser does: it creates the request

The URL break-down

SCHEME :// AUTHORITY / PATH ? QUERY # FRAGMENT
protocol host & port path arguments / data location in page

Status codes

MDN status codes

Status codes

cat status codes

3

Flask

Flask

Python program that listens for requests
and sends back responses

Example

a simple example
“hello world”

Want a bigger example?

your buggy editor!