Adding invoke, and refactoring app structure
							parent
							
								
									a86ac17fd6
								
							
						
					
					
						commit
						19733455ac
					
				@ -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
 | 
					import datetime as dt
 | 
				
			||||||
from fastapi import FastAPI
 | 
					from fastapi import FastAPI
 | 
				
			||||||
 | 
					
 | 
				
			||||||
app = FastAPI()
 | 
					from app.api import ping
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					app = FastAPI()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@app.get('/ping')
 | 
					app.include_router(ping.router)
 | 
				
			||||||
async def pong():
 | 
					 | 
				
			||||||
    now = dt.datetime.now(dt.timezone.utc)
 | 
					 | 
				
			||||||
    return {'ping': "pong!", 'now': now}
 | 
					 | 
				
			||||||
 | 
				
			|||||||
@ -1,9 +1,9 @@
 | 
				
			|||||||
from invoke import task
 | 
					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
 | 
					@task
 | 
				
			||||||
def serve(c):
 | 
					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}")
 | 
					    c.run(f"pushd services/api && {UNVICORN_CMD}")
 | 
				
			||||||
 | 
				
			|||||||
					Loading…
					
					
				
		Reference in New Issue