FastAPI backend for Repost

Overview

Repost FastAPI

This is the FastAPI implementation of the Repost API.

Installation

Python 3 must be installed and accessible through the use of a terminal and the keyword python or python3. Below are the steps for a proper setup using VENV (Python Virtual Environment).

  1. Clone the repository
git clone https://github.com/pckv/repost-fastapi.git
  1. Navigate to the repost-fastapi directory and create a new VENV
cd repost-fastapi
python -m venv venv

3 (Linux). Activate the venv (alternatively: run all commands after this step prefixed with venv/bin/)

source venv/bin/activate

3 (Windows). Activate the venv (alternatively: run all commands after this step prefixed with venv\Scripts\)

venv\Scripts\activate
  1. Install the required packages
pip install -r requirements.txt

Configurations

Configurations are set by environment variables. Follow the instructions below to run the server once and a file config.env will be created in the root directory. Otherwise, the following settings can also be set using exported environment variables.

  • REPOST_CLIENT_ID - The OAuth2 client_id. Default is repost
  • REPOST_JWT_SECRET - The secret key used for JSON Web Tokens
  • REPOST_JWT_ALGORIGHTM - The algorithm used for the key above
  • REPOST_DATABASE_URL - An SQLAlchemy database url. See Engine Configuration
  • REPOST_ORIGINS - A list of CORS URLs separated by ;

Running the API with uvicorn

Uvicorn is a single-threaded ASGI server designed around uvloop to run fast. It is included in the requirements and should be used to run the API.

uvicorn repost:app

The default host and port is localhost and 8000. They can be changed with the --host and --port arguments. To run the server publically, set the host to 0.0.0.0 like so.

uvicorn repost:app --host 0.0.0.0

Running the API with gunicorn

Gunicorn is a WSGI server that can manage multiple workers. Uvicorn has a worker for Gunicorn that can be used to run multiple Uvicorn workers. Since Repost is a stateless API, this works perfectly and will allow utilizing more processing power.

gunicorn repost:app -w 17 -k uvicorn.workers.UvicornWorker

The example above uses 17 workers for a system with 8 CPUs (16 threads + 1 workers). This value can be tweaked to your setup. You can also set the host and port in gunicorn with the -b argument, which includes both host and port in the same argument.

gunicorn repost:app -b 0.0.0.0:8000 -w 17 -k uvicorn.workers.UvicornWorker

Documentation

Documentation for the API is available after deployment at the /api/swagger and /api/docs endpoints.

Owner
PC
Computer engineer @Safepath-AS
PC
FastAPI Project Template

The base to start an openapi project featuring: SQLModel, Typer, FastAPI, JWT Token Auth, Interactive Shell, Management Commands.

A.Freud 4 Dec 05, 2022
Qwerkey is a social media platform for connecting and learning more about mechanical keyboards built on React and Redux in the frontend and Flask in the backend on top of a PostgreSQL database.

Flask React Project This is the backend for the Flask React project. Getting started Clone this repository (only this branch) git clone https://github

Peter Mai 22 Dec 20, 2022
Deploy/View images to database sqlite with fastapi

Deploy/View images to database sqlite with fastapi cd realistic Dependencies dat

Fredh Macau 1 Jan 04, 2022
The template for building scalable web APIs based on FastAPI, Tortoise ORM and other.

FastAPI and Tortoise ORM. Powerful but simple template for web APIs w/ FastAPI (as web framework) and Tortoise-ORM (for working via database without h

prostomarkeloff 95 Jan 08, 2023
Generate Class & Decorators for your FastAPI project โœจ๐Ÿš€

Classes and Decorators to use FastAPI with class based routing. In particular this allows you to construct an instance of a class and have methods of that instance be route handlers for FastAPI & Pyt

Yasser Tahiri 34 Oct 27, 2022
Docker image with Uvicorn managed by Gunicorn for high-performance FastAPI web applications in Python 3.6 and above with performance auto-tuning. Optionally with Alpine Linux.

Supported tags and respective Dockerfile links python3.8, latest (Dockerfile) python3.7, (Dockerfile) python3.6 (Dockerfile) python3.8-slim (Dockerfil

Sebastiรกn Ramรญrez 2.1k Dec 31, 2022
์Šคํƒ€ํŠธ์—… ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ

์Šคํƒ€ํŠธ์—… ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ ๅคง ๋ฐ•๋žŒํšŒ Seed ~ Series B์— ์žˆ๋Š” ์Šคํƒ€ํŠธ์—…์„ ์œ„ํ•œ ์ฑ„์šฉ์ •๋ณด ํŽ˜์ด์ง€์ž…๋‹ˆ๋‹ค. Back-end, Frontend, Mobile ๋“ฑ ๊ฐœ๋ฐœ์ž๋ฅผ ๋Œ€์ƒ์œผ๋กœ ์ง„ํ–‰ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ํ•ด๋‹น ์Šคํƒ€ํŠธ์—…์— ์ข…์‚ฌํ•˜์‹œ๋Š” ๋ถ„๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ์ฑ„์šฉ ๊ด€๋ จ ์ •๋ณด๋ฅผ ์•Œ๊ณ  ๊ณ„์‹œ๋‹ค๋ฉด

JuHyun Lee 58 Dec 14, 2022
Asynchronous event dispatching/handling library for FastAPI and Starlette

fastapi-events An event dispatching/handling library for FastAPI, and Starlette. Features: straightforward API to emit events anywhere in your code ev

Melvin 238 Jan 07, 2023
A RESTful API for creating and monitoring resource components of a hypothetical build system. Built with FastAPI and pydantic. Complete with testing and CI.

diskspace-monitor-CRUD Background The build system is part of a large environment with a multitude of different components. Many of the components hav

Nick Hopewell 67 Dec 14, 2022
Boilerplate code for quick docker implementation of REST API with JWT Authentication using FastAPI, PostgreSQL and PgAdmin โญ

FRDP Boilerplate code for quick docker implementation of REST API with JWT Authentication using FastAPI, PostgreSQL and PgAdmin โ› . Getting Started Fe

BnademOverflow 53 Dec 29, 2022
Single Page App with Flask and Vue.js

Developing a Single Page App with FastAPI and Vue.js Want to learn how to build this? Check out the post. Want to use this project? Build the images a

91 Jan 05, 2023
Code Specialist 27 Oct 16, 2022
FastAPI application and service structure for a more maintainable codebase

Abstracting FastAPI Services See this article for more information: https://camillovisini.com/article/abstracting-fastapi-services/ Poetry poetry inst

Camillo Visini 309 Jan 04, 2023
A utility that allows you to use DI in fastapi without Depends()

fastapi-better-di What is this ? fastapi-better-di is a utility that allows you to use DI in fastapi without Depends() Installation pip install fastap

Maxim 9 May 24, 2022
Opinionated set of utilities on top of FastAPI

FastAPI Contrib Opinionated set of utilities on top of FastAPI Free software: MIT license Documentation: https://fastapi-contrib.readthedocs.io. Featu

identix.one 543 Jan 05, 2023
Simple notes app backend using Python's FastAPI framework.

my-notes-app Simple notes app backend using Python's FastAPI framework. Route "/": User login (GET): return 200, list of all of their notes; User sign

Josรฉ Gabriel Mourรฃo Bezerra 2 Sep 17, 2022
Full stack, modern web application generator. Using FastAPI, PostgreSQL as database, Docker, automatic HTTPS and more.

Full Stack FastAPI and PostgreSQL - Base Project Generator Generate a backend and frontend stack using Python, including interactive API documentation

Sebastiรกn Ramรญrez 10.8k Jan 08, 2023
REST API with FastAPI and JSON file.

FastAPI RESTAPI with a JSON py 3.10 First, to install all dependencies, in ./src/: python -m pip install -r requirements.txt Second, into the ./src/

Luis Quiรฑones Requelme 1 Dec 15, 2021
Lightning FastAPI

Lightning FastAPI Lightning FastAPI framework, provides boiler plates for FastAPI based on Django Framework Explaination / | โ”‚ manage.py โ”‚ README.

Rajesh Joshi 1 Oct 15, 2021
Twitter API monitor with fastAPI + MongoDB

Twitter API monitor with fastAPI + MongoDB You need to have a file .env with the following variables: DB_URL="mongodb+srv://mongodb_path" DB_URL2=

Leonardo Ferreira 3 Apr 08, 2022