|
@@ -1,21 +1,13 @@
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
-from fastapi import Depends, FastAPI, Header, HTTPException
|
|
|
+import uvicorn
|
|
|
+from fastapi import FastAPI
|
|
|
|
|
|
-from .api.routers import items, users
|
|
|
+from app.api.routers import targets
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
+app.include_router(targets.router, prefix='/targets')
|
|
|
|
|
|
-async def get_token_header(x_token: str = Header(...)):
|
|
|
- if x_token != 'fake-super-secret-token':
|
|
|
- raise HTTPException(status_code=400, detail='X-Token header invalid')
|
|
|
-
|
|
|
-app.include_router(users.router)
|
|
|
-app.include_router(
|
|
|
- items.router,
|
|
|
- prefix='/items',
|
|
|
- tags=['items'],
|
|
|
- dependencies=[Depends(get_token_header)],
|
|
|
- responses={404: {'description': 'Not found'}},
|
|
|
-)
|
|
|
+if __name__ == '__main__':
|
|
|
+ uvicorn.run(app, host='0.0.0.0', port=8000)
|