项目作者: zeshuaro

项目描述 :
COVID-19 Dashboard REST API Client
高级语言: Python
项目地址: git://github.com/zeshuaro/covid-19-dashboard-api.git
创建时间: 2020-04-27T03:25:17Z
项目社区:https://github.com/zeshuaro/covid-19-dashboard-api

开源协议:MIT License

下载


COVID-19 Dashboard API

A REST API client for the COVID-19 Dasoboard

Getting Started

Create your .env file

Run the following command to generate a secret key first:

  1. openssl rand -hex 32

Then add the followings to your .env file:

  1. SECRET_KEY=<SECRET_KEY>
  2. ALGORITHM="HS256"
  3. ACCESS_TOKEN_EXPIRE_DAYS=<TOKEN_LIFETIME_IN_DAYS>

Setup virtual environment if you haven’t done so

  1. virtualenv venv
  2. source venv/bin/activate

Install the dependencies

  1. pip install -r requirements.txt

Setup your database

The app relies on Firestore on Google Cloud Platform (GCP). Create a project on GCP and initialise your Firestore database in native mode. Make sure you also initialise gcloud cli with gcloud init.

Obtain a hashed password with the following python code:

  1. from passlib.context import CryptContext
  2. pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
  3. password="your_password"
  4. print(pwd_context.hash(password))

Finally on Firestore, create a users collection and add a document with the followng fields:

  1. {
  2. "username": "username",
  3. "hashed_password": "hashed_password",
  4. "disabled": false
  5. }

Run the app

  1. uvicorn app.main:app --reload

Go to http://127.0.0.1:8000/docs for Swagger docs or http://127.0.0.1:8000/redoc for ReDoc