Creating an API with FastAPI
This guide will walk through the process of developing a FASTAPI and deploying to an AWS EC2 instance with a custom domain and SSL/HTTPS certification.
Create Virtual Environment
mkdir fastapi
cd fastapi
python3 -m venv env
source env/bin/activateCreate a FASTAPI project
pip install fastapi uvicornCreate main.py
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}Launch API
# Launch Uvicorn and load main.py app
sudo /home/ubuntu/fastapi/env/bin/uvicorn
sudo /home/ubuntu/fastapi/main:app --reloadVisit Documentation
https://fastapi.tiangolo.com/tutorial/
Creating a FastAPI Ubuntu service
[Optional] Create a Monitor with Monit
Websockets
Last updated