mirror of
https://github.com/UofCBaja/Interview-Backend.git
synced 2025-06-15 13:24:19 -06:00
feat(Packagers): tested out FastAPI its a great wrapper comes with auto docs/test tool that shows how to do the api request, marginally slower
This commit is contained in:
parent
0276fea6e7
commit
fcbee342b3
BIN
FastAPI test 1000 requests.png
Normal file
BIN
FastAPI test 1000 requests.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
__pycache__/newMain.cpython-312.pyc
Normal file
BIN
__pycache__/newMain.cpython-312.pyc
Normal file
Binary file not shown.
43
newMain.py
Normal file
43
newMain.py
Normal file
@ -0,0 +1,43 @@
|
||||
import json
|
||||
from fastapi import FastAPI
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
@app.get("/")
|
||||
def get_root():
|
||||
res = {"message": "Hello World"}
|
||||
|
||||
# Return the response with the custom header
|
||||
return JSONResponse(
|
||||
headers={
|
||||
"isBase64Encoded": "false", # Header Modification
|
||||
},
|
||||
content={
|
||||
"body": res
|
||||
},
|
||||
|
||||
# status_code=200 commented out just to show how to change it if you wanted
|
||||
)
|
||||
|
||||
|
||||
# # Set headers
|
||||
# headers = {
|
||||
# "isBase64Encoded": "false", # Header Modification
|
||||
# }
|
||||
|
||||
from GetSchedulePackager import getSchedulePackager
|
||||
|
||||
@app.get("/getSchedule")
|
||||
def getSchedule():
|
||||
res = getSchedulePackager()
|
||||
return JSONResponse(
|
||||
headers={
|
||||
"isBase64Encoded": "false", # Header Modification
|
||||
},
|
||||
content={
|
||||
"body": res
|
||||
},
|
||||
|
||||
# status_code=200 commented out just to show how to change it if you wanted
|
||||
)
|
@ -15,4 +15,4 @@ def BenchMarkDjango():
|
||||
if __name__ == "__main__":
|
||||
djangoTime = timeit.timeit(stmt=BenchMarkDjango, number=10)
|
||||
pythonTime = timeit.timeit(stmt=BenchMarkServer, number=10)
|
||||
print(f"Django: {djangoTime}\nPython: {pythonTime}")
|
||||
print(f"FastAPI: {djangoTime}\nPython: {pythonTime}")
|
Loading…
x
Reference in New Issue
Block a user