Example
Define an API
# main.py
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Data(BaseModel):
msg: str
@app.post("/")
def handle_async(data: Data):
return dataCreate a Dockerfile
DockerfileFROM python:3.8-slim
RUN pip install --no-cache-dir fastapi uvicorn
COPY main.py /
CMD uvicorn --host 0.0.0.0 --port 8080 main:appBuild an image
Run a container locally
Make a request
Login to ECR
Create a repository
Tag the image
Push the image
Configure a Cortex deployment
Create a Cortex deployment
Wait for the API to be ready
Get the API endpoint
Make a request
Get the response
Last updated