Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kiminzajnr/rest-api
A complete REST API built with Flask and Python
https://github.com/kiminzajnr/rest-api
docker flask-api flask-restful flask-smorest jwt-authentication mailgun-api python3 render-deployment swagger-ui
Last synced: about 7 hours ago
JSON representation
A complete REST API built with Flask and Python
- Host: GitHub
- URL: https://github.com/kiminzajnr/rest-api
- Owner: kiminzajnr
- License: mit
- Created: 2024-06-03T16:41:56.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2024-07-02T22:16:08.000Z (6 months ago)
- Last Synced: 2025-01-05T01:13:52.771Z (about 7 hours ago)
- Topics: docker, flask-api, flask-restful, flask-smorest, jwt-authentication, mailgun-api, python3, render-deployment, swagger-ui
- Language: Python
- Homepage: https://know-us-rest-api.discoverwitherick.tech/swagger-ui
- Size: 90.3 MB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Know-US States REST API
A complete REST API built with Flask and Python![API Screenshot](/sc.png)
# API Endpoints
## Users
| Method | Endpoint | Description |
|--------|-------------------|---------------------------------------------------|
| POST | /register | Create user accounts given an email and password. |
| POST | /login | Get a JWT given an email and password. |
| 🔒 POST | /logout | Revoke a JWT. |
| 🔒 POST | /refresh | Get a fresh JWT given a refresh JWT. |
| GET | /user/{user_id} | (dev-only) Get info about a user given their ID. |
| DELETE | /user/{user_id} | (dev-only) Delete a user given their ID. |## States
| Method | Endpoint | Description |
|--------|-------------------|---------------------------------------------------|
| POST | /state | Create a state given a its name. |
| GET | /state | Get a list of states. |
| GET | /state/{state_id} | Delete a state given its ID. |
| DELETE | /state/{state_id} | Get a state given its ID. |## Cities
| Method | Endpoint | Description |
|--------|-------------------|---------------------------------------------------|
| POST | /city | Create a city given its name and state ID. |
| GET | /city | Get a list of cities. |
| GET | /city/{city_id} | Get a city given its ID. |
| PUT | /city/{city_id} | Update a city given its ID. |
| DELETE | /city/{user_id} | Delete a city given its ID. |# Setup
## Using virtual env
```
git clone https://github.com/kiminzajnr/RESTful-Flask-API.git
cd RESTful-Flask-API
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
```#### Run the app
```
flask run
```## Using docker
```
git clone https://github.com/kiminzajnr/RESTful-Flask-API.git
cd RESTful-Flask-API
docker build -t flask-api .
docker run -dp 5000:5000 -w /app -v "$(pwd):/app" flask-api
```#### Common errors when using docker
`Error response from daemon: Ports are not available: exposing port TCP 0.0.0.0:5000 -> 0.0.0.0:0: listen tcp 0.0.0.0:5000: bind: address already in use.`- Use another port:
- `docker run -dp 5005:5000 -w /app -v "$(pwd):/app" flask-api`
- Or, kill process running on the port if not needed:
- Run `lsof -i :5000` and note the `PID`
- Run `kill -9 PID` - `PID` obtained from above`docker: Cannot connect to the Docker daemon at ... docker.sock. Is the docker daemon running?.`
- If on macOS/Windows run docker desktop.
- On Linux start docker service.# Usage
![Usage Video](/output.gif)
# License
[MIT license](/LICENSE)