Giter Site home page Giter Site logo

kiminzajnr / rest-api Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 92.46 MB

A complete REST API built with Flask and Python

Home Page: https://know-us-rest-api.discoverwitherick.tech/swagger-ui

License: MIT License

Python 68.52% Dockerfile 0.73% Shell 0.43% Mako 1.96% HTML 28.35%
docker flask-api flask-restful flask-smorest jwt-authentication python3 render-deployment swagger-ui mailgun-api

rest-api's Introduction

Know-US States REST API

A complete REST API built with Flask and Python

API Screenshot

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

License

MIT license

rest-api's People

Contributors

kiminzajnr avatar

Watchers

 avatar

Forkers

ustaz07

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.