platzi-twitter-api-fastapi
platzi-twitter-api-fastapi copied to clipboard
A simple REST API made with FastAPI for learning purposes.
Platzi - Twitter API
This project is part of the course "Curso de FastAPI: Modularización, Datos Avanzados y Errores " of "Platzi"
Table of Contents:
-
Description
- Features
- Requirements
-
Installation
- Using docker
- Normal
- Usage
Description
This is project is a simple REST API made with FastAPI for learning purposes.
Features
Features included:
- Data modeling with pydantic.
- Data validation.
- CRUD of users.
- CRUD of Tweets.
- SQLAlchemy (MYSQL)
- Docker dev environment
- JWT Authentication
- FastAPI Router
- MyPY
Requirements:
- Python >= 3.6
- Docker and Docker Compose (Optionally)
Installation
-
Clone or download de repository:
$ git clone https://github.com/JoseNoriegaa/platzi-twitter-api-fastapi
-
Open the console inside the project directory and create a virtual environment (You can skip this step if you have docker installed).
$ python3 -m venv venv $ source venv/bin/activate
-
Install the app (You can skip this step if you have docker installed)
(venv) $ pip install -r requirements.txt
Run it locally
Copy the env.example
file into the same directory with the name .env
$ cp ./env.example ./.env
With docker
- Run it with Docker Compose.
docker-compose up
Without docker
- Configure the environment variables into the
.env
.
# App
SECRET_KEY=rVsvupYHUbAgOGNMw0ytII_7tkn_iWkBhktVR_i3Tg8= # You can leave this dev key as is.
DEBUG=True # If DEBUG = True, the reload option of uvicorn will be enabled
PORT=8000 # Server port
# Database
DATABASE_URL=mysql+pymysql://${YOUR_USER}:${YOUR_PASSWORD}@${HOST}:${PORT}/${DATABASE NAME} # Configure your database credentials here.
- Run the server.
$ python3 main.py
Basic Usage
Once you are running the server open the Swagger UI App to checkout the API documentation.