Sidecar Tutorial: Server-side
fastapi
uvicorn# Create virtual environment for python project.
python -m venv venv# Activate virtual environment
source venv/bin/activate # install required dependencies
pip install -r requirements.txt# FastApi Setup for the Quick Start Tutorial
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import uvicorn
# Initiates the FastApi instance
app = FastAPI()
# Enabling CORS to allow access for the Client-side App.
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Route for our API on index page to send over a simple message.
@app.get("/")
async def index():
return {"message": "Welcome to IndustryApps!"}
Last updated