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 + ) + '''