-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
37 lines (23 loc) · 844 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
28
29
30
31
32
33
34
35
36
37
from fastapi import FastAPI, Response
# I like to launch directly and not use the standard FastAPI startup
import uvicorn
from resources.students import StudentsResource
app = FastAPI()
students_resource = StudentsResource()
@app.get("/")
async def root():
return {"message": "Hello World"}
@app.get("/hello/{name}")
async def say_hello(name: str):
return {"message": f"Awesome cloud developer dff9 says hello {name}"}
@app.get("/hello_text/{name}")
async def say_hello_text(name: str):
the_message = f"Awesome cloud developer dff9 says Hello {name}"
rsp = Response(content=the_message, media_type="text/plain")
return rsp
@app.get("/students")
async def get_students():
result = students_resource.get_students()
return result
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8012)