Adding invoke, and refactoring app structure

master
Drew Bednar 4 years ago
parent a86ac17fd6
commit 19733455ac

@ -3,7 +3,7 @@ version: '3.7'
services:
api:
build: ./services/api
command: uvicorn app.main:app --reload --workers 1 --host 0.0.0.0 --port 8000
command: uvicorn api.main:api --reload --workers 1 --host 0.0.0.0 --port 8000
volumes:
- ./services/api/:/opt/fast_api/
ports:

@ -0,0 +1,10 @@
import datetime as dt
from fastapi import APIRouter
router = APIRouter()
@router.get('/ping')
async def pong():
now = dt.datetime.now(dt.timezone.utc)
return {'ping': "pong!", 'now': now}

@ -1,10 +1,8 @@
import datetime as dt
from fastapi import FastAPI
app = FastAPI()
from app.api import ping
app = FastAPI()
@app.get('/ping')
async def pong():
now = dt.datetime.now(dt.timezone.utc)
return {'ping': "pong!", 'now': now}
app.include_router(ping.router)

@ -1,9 +1,9 @@
from invoke import task
UNVICORN_CMD = "uvicorn app.main:app --reload --workers 1 --host 0.0.0.0 --port 8000"
UNVICORN_CMD = "uvicorn api.main:api --reload --workers 1 --host 0.0.0.0 --port 8000"
@task
def serve(c):
"""Serves the fast_api app for local development"""
"""Serves the fast_api api for local development"""
c.run(f"pushd services/api && {UNVICORN_CMD}")

Loading…
Cancel
Save