This repo is for learning how to use FastAPI.
The code in this tutorial is found in the official documentation for FastAPI: https://fastapi.tiangolo.com/.
The server is an Ubuntu 18.4 LTS on AWS and can be connected using the following command where the .pem file is the SSH key:
ssh -i "fastapi.pem" [email protected]
sudo docker build -t fastapi-image .
sudo docker start fastapi-container
http://ec2-34-253-214-90.eu-west-1.compute.amazonaws.com/redoc
Make sure you have installed the requirements found in requirements.txt in a virtual environment using tools such as conda or virtualenv.
uvicorn main:app --reload
import requests
url = "localhost:8000/items/2"
payload="{\n \"name\": \"string\",\n \"price\" : 0\n}"
headers = {
'Content-Type': 'application/json'
}
response = requests.request("PUT", url, headers=headers, data=payload)
print(response.text)
curl --location --request PUT 'localhost:8000/items/2' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "string",
"price" : 0
}'