From 0276fea6e7a4f94c20c9fb205d282dacb62a1cd0 Mon Sep 17 00:00:00 2001 From: darkicewolf50 <95242911+darkicewolf50@users.noreply.github.com> Date: Wed, 27 Nov 2024 17:58:01 -0700 Subject: [PATCH] feat(Packagers): testing out fastapi for performance --- djangotutorial/mysite/newtest.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/djangotutorial/mysite/newtest.py b/djangotutorial/mysite/newtest.py index 210ee0e..693c0df 100644 --- a/djangotutorial/mysite/newtest.py +++ b/djangotutorial/mysite/newtest.py @@ -14,4 +14,34 @@ def index(request): response['X-IsBase64Encoded'] = 'false' # Custom header to indicate base64 encoding response.status_code = 200 return response + +from fastapi import FastAPI +from fastapi.responses import JSONResponse + +app = FastAPI() + +@app.get("/") +async def index(): + ymlschedule = {"message": False} + + # Create the response body with multiple items + res = { + "body": { + "Schedule": ymlschedule, # FastAPI will automatically serialize the dictionary + "message": "good", + } + } + + # Set custom headers + headers = { + "isBase64Encoded": "false", # Custom header + } + + # Return the response with the custom header + return JSONResponse( + content=res, + headers=headers, + # status_code=200 commented out just to show how to change it if you wanted + ) + '''