Project 4 Introduction W22

pptx

School

University of Michigan *

*We aren’t endorsed by this school

Course

280

Subject

Computer Science

Date

Apr 3, 2024

Type

pptx

Pages

13

Uploaded by jjuett

Report
Project 4 introduction
API.exe While(read_request()) 1. read request from cin 2. read/write list (queue) data structure 3. write response to cout
Request types - GET - “Gets” information from the server - POST - Posts new information to the server - DELETE - Deletes information from the server
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
GET requests - /api/ - Returns all the URLs supported by the API - /api/queue/head/ - Returns the person at the head of the queue - /api/queue/ - Returns the entire queue contents GET /api/queue/head/ HTTP/1.1
POST request - /api/queue/tail/ - Tells the server to put a new person on the end of the queue - Person inputted using JSON body POST /api/queue/tail/ HTTP/1.1 *HEADERS* { "uniqname": "jackgood", "location": "Table 5" }
DELETE Request - /api/queue/head/ - Tells the server to remove the person at the top of the queue DELETE /api/queue/head/ HTTP/1.1
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Request breakdown POST /api/queue/tail/ HTTP/1.1 Host: localhost Content-Type: application/json; charset=utf-8 Content-Length: 57 { "uniqname": "jackgood", "location": "Table 5" } Request Type Endpoint Number of characters in body Empty Line Body
Response breakdown HTTP/1.1 200 OK Content-Type: application/json; charset=utf-8 Content-Length: 76 { "location": "Table 3", "position": 1, "uniqname": "awdeorio" } Response code Number of characters in body Empty Line Body
Response breakdown HTTP/1.1 201 Created Content-Type: application/json; charset=utf-8 Content-Length: 76 { "location": "Table 5", "position": 1, "uniqname": "jackgood" } Response code Number of characters in body Empty Line Body
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Response breakdown HTTP/1.1 400 Bad Request Content-Type: application/json; charset=utf-8 Content-Length: 0 Response code Number of characters in body Empty Line Body (none this time)
Python server Wrapper combining “api.exe”, gui, and network interface Receives network requests on localhost port 8000 Runs ./api.exe and pipes I/O correctly - network requests piped into api.exe - output from api.exe forwarded back over network and to debug terminal Use this for further testing/debugging (past the given files) - creating/passing properly formatted input to the api.exe is painful
When should the program finish? - always read an entire request header (and body if it exists) - Assume the header/body is well formed - If the program ever fails to read the beginning of a new request, then “return 0” - returns on EOF for the autograder, runs forever for browser Basically: while(cin >> method >> endpoint) method = “GET” endpoint = “/api/queue/head/”
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Request breakdown POST /api/queue/tail/ HTTP/1.1 Host: localhost Content-Type: application/json; charset=utf-8 Content-Length: 57 { "uniqname": "jackgood", "location": "Table 5" } Request Type Endpoint Number of characters in body Empty Line Body