Skip to content

dta-63/fastapi-sample

Repository files navigation

FastApi sample

CircleCI

Example of a python microservices using FastApi framework

Requirements

Requirements

Features

  • Service documentation (Open api)
  • Multiple environments with dotenv
  • Docker
  • Mongo connector with Motor
  • Authentication check (Test with keycloak)
  • Authentication roles check (Test with keycloak)
  • CI
  • Unit test with pytest
  • Cache
  • Kafka producer
  • Kafka consumer
  • Jobs with Apache Airflow

Start

  • Run ./make.sh to build the virtual env
  • Activate python virtual env :
    • For linux : source env/bin/activate
    • For windows : source env/Scripts/activate
  • Copy and set .env-sample to .env, edit variables
  • Run python main.py or use a launcher in VScode
  • Access to http://127.0.0.1:8080/
  • Access to http://127.0.0.1:8080/docs for swagger
  • Access to http://127.0.0.1:8080/redoc for Redoc
  • Set WEB_CONCURRENCY environment variable for number of workers

Tests

  • Write tests in tests folder
  • File pattern should be *_test.py
  • Run with the command pytest

Helpfull links

Init other micro service

  • Use the script ./init_from_sample.sh

About

Python fastapi framework sample

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published