-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.py
More file actions
37 lines (31 loc) · 732 Bytes
/
main.py
File metadata and controls
37 lines (31 loc) · 732 Bytes
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
28
29
30
31
32
33
34
35
36
37
import uvicorn
from fastapi import FastAPI, Form
from starlette.middleware.cors import CORSMiddleware
import slots
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # Allows all origins
allow_credentials=True,
allow_methods=["GET", "POST"],
allow_headers=["*"],
)
def clear():
slots.already = {
"MON": {},
"TUE": {},
"WED": {},
"THU": {},
"FRI": {}
}
@app.get("/")
async def testing():
"""Check if server is working"""
return "Ok! Working!"
@app.post("/fetch/")
async def get_timetable(request: str = Form(...)):
data = slots.fetch_info(request)
clear()
return data
if __name__ == "__main__":
uvicorn.run(app)