https://github.com/ronierisonmaciel/fastapi
https://github.com/ronierisonmaciel/fastapi
aws-ec2 fastapi json json-schema python
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ronierisonmaciel/fastapi
- Owner: RonierisonMaciel
- Created: 2022-11-30T03:17:48.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-12-13T21:58:54.000Z (over 2 years ago)
- Last Synced: 2025-01-30T23:30:49.585Z (4 months ago)
- Topics: aws-ec2, fastapi, json, json-schema, python
- Language: Python
- Homepage:
- Size: 31.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FastAPI Tutorial
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.7+ based on standard Python type hints.
This is a simple example FastAPI application that pretends to be a planets.
# Deploying to AWS EC2
Log into your AWS account and create an EC2 instance (`t2.micro`), using the latest stable
Ubuntu Linux AMI.[Amazon EC2 Getting Started](https://aws.amazon.com/pt/ec2/getting-started/) and run these commands to update the software repository and install
our dependencies.```bash
sudo apt-get update
sudo apt install -y python3-pip nginx
```Clone the FastAPI server app (or create your `main.py` in Python).
```bash
git clone [email protected]:RonierisonMaciel/fastapi.git
``````bash
cd fastapi
pip3 install -r dev-requirements.txt
```Add the FastAPI configuration to NGINX's folder. Create a file called `fastapi_nginx` (like the one in this repository).
```bash
sudo nano /etc/nginx/sites-enabled/fastapi_nginx
```And put this config into the file (replace the IP address with your EC2 instance's public IP):
```
server {
listen 80;
server_name ;
location / {
proxy_pass http://127.0.0.1:8000;
}
}
```Start NGINX.
```bash
sudo service nginx restart
```Start FastAPI.
```bash
cd fastapi
python3 -m uvicorn swapi.main:app
```Update EC2 security-group settings for your instance to allow HTTP traffic to port 80.
Now when you visit your public IP of the instance, you should be able to access your API.
## Interactive API docs
```bash
http:/api/planets/
http:/docs
http:/redoc
```