L14. Server-Side Web Architectures + REST
CSCI 344: Advanced Web Technologies
Fall 2024
Announcements
Today’s Topic
What’s New with Server-Side Programming
Outline
Outline
Static Web Page
Architecture
Weeks 1-6
Tutorials 2-6
Homework 2
Dynamic, Client-Side Architecture
Weeks 11-13, Tutorials 7-8, HW 3-4
Server-Side Architecture
Weeks 14-18, Tutorials 9-11, HW 5-6
Two Families of Web Architectures
There are two main families of web architectures:
Outline
Recall from Week 6
API → “Application Programming Interface”
A set of rules that you have to follow to interact with a piece of software
Web API
An API that you access via HTTP protocol. Offers a systematic way to:
In other words, Web APIs allow others to take advantage of resources distributed across providers, servers, organizations, etc.
12
Who uses Web APIs?
Everyone!
Standardizing HTTP Interfaces
A variety of different solutions to this problem
Web APIs & the REST Architecture
One popular way of building a Web API is by following the REST architecture guidelines. Some facts about REST:
16
Resource-Oriented Architecture
17
1. Resource
Noun. The thing that is being represented by data / a document
18
Note the plural convention for detail resources
1. Resource
Example of a resource: https://<server_address>/api/posts/22
{
"image_url": "https://picsum.photos/600/430",
"user": {
"first_name": "Timothy",
"last_name": "Myers",
"username": "timothy_myers",� ...
},
"caption": "Spend catch ready administration success..."
"likes": 853
}
19
2. Addressability
20
2. Addressability: Examples
Container/List Resource (create and read):
�Detail Resource (update, delete):
21
3. Statelessness
Means that there is no “stored context” or memory across transactions:
22
4. Connectedness
You should be able to connect / discover relationships between resources from the resource representation. Example (Comment):
{
"text": "Text text text....",
"post_id": 6,
"user": {
"first_name": "Emily",
"last_name": "Terry",
"username": "emily_terry",
"email": "emily_terry@gmail.com",
...
}
}
23
5. Uniform Interface
“Interface” — refers to the way we interact with and modify resources.
�In REST All resources are created, updated, read, and deleted in the same way, using the HTTP protocol methods (verbs), which are defined in the header of the request. Here are some of them:
24
GET
Retrieves / reads a resource (or container of resources) from an address on a server
�NEVER modify a resource using the GET method – you can do it (technically) but you never should.
25
POST
Creates a NEW resource on a server; usually done by posting to the container endpoint:
26
PUT & PATCH
PUT: Replaces a single resource on a server
PATCH: Updates part of a resource on a server
27
DELETE
Permanently deletes a resource on a server
28
HTTP Status Codes
Use the status codes to help your client understand success and failure. Here is a list of them.
For HW1 and HW2...
References / Credits
Much of this REST overview was derived from:
RESTful Web Services�https://www.slideshare.net/cebartling/rest-web-services
30
Clients
You can access a REST API via many different clients (including):
Outline
Activity: Postman
Postman is a popular API development and testing tool. It provides a user-friendly interface for sending HTTP requests to APIs and receiving responses, making it easier for developers to build, test, and debug web APIs. To use it:
33