-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
27 lines (19 loc) · 617 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from typing import Optional
from fastapi import FastAPI
import json
from fastapi.encoders import jsonable_encoder
from fastapi.responses import JSONResponse
app = FastAPI()
data_fp = 'student_classes_data.json'
with open(data_fp, "r") as read_file:
data = json.load(read_file)
print(type(data['cbowles22@choate.edu']))
@app.get("/")
def read_root():
return {"message": "Yo hey wassup try /classes/{email}"}
@app.get("/classes/{email}")
def read_classes(email: str):
return JSONResponse(content=json.dumps(data[email]))
@app.get("/questions")
def read_questions():
return {"data": "some data"}