This project pretends to be a copy of the twitter api.
This is project is a simple REST API made with FastAPI for learning purposes.
Features included:
- Data modeling with pydantic.
- Data validation.
- CRUD of users.
- CRUD of Tweets.
- SQLAlchemy (MYSQL)
- Docker dev environment
- JWT Authentication
- FastAPI Router
- MyPY
- Python >= 3.6
- Docker and Docker Compose (Optionally)
-
Clone or download de repository:
$ git clone git@github.com:JuanCarlosAguilarB/apirest-twitter.git
-
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
Copy the env.example
file into the same directory with the name .env
$ cp ./env.example ./.env
- Run it with Docker Compose.
docker-compose up
- 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
Once you are running the server open the Swagger UI App or http://localhost:8000/docs to checkout the API documentation.