Skip to content

Instantly share code, notes, and snippets.

@rajavijaysingh
Forked from Cox65/fastapi_app.py
Created September 10, 2024 12:51
Show Gist options
  • Save rajavijaysingh/ac5caede04c79ba7c504a16574bf7f8d to your computer and use it in GitHub Desktop.
Save rajavijaysingh/ac5caede04c79ba7c504a16574bf7f8d to your computer and use it in GitHub Desktop.
FastAPI AWS Starter Kit
from fastapi import FastAPI
from starlette.middleware.cors import CORSMiddleware
app = FastAPI(title="Sample FastAPI app", debug=False, version="1.0.0")
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
@app.get(
path="/health", description="Health check"
)
def health_check():
return {"status": "OK"}
from mangum import Mangum
from fastapi_aws_starter_kit.fastapi_app import app
handler = Mangum(app=app)
org: cox65
app: fastapi-aws-starter-kit
service: fastapi-aws-starter-kit
package:
individually: true
provider:
name: aws
runtime: python3.9
region: eu-west-1
httpApi:
cors: true
timeout: 10
memorySize: 128
plugins:
- serverless-python-requirements
- serverless-offline
functions:
app:
package:
patterns:
- "fastapi_aws_starter_kit/**"
handler: fastapi_aws_starter_kit.handler.handler
events:
- http:
method: any
path: /{proxy+}
cors: true
custom:
pythonRequirements:
dockerizePip: true
import os
import uvicorn
if __name__ == "__main__":
uvicorn.run(
"fastapi_app:app",
host="127.0.0.1",
port=5000,
reload=True,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment