diff options
-rw-r--r-- | __main__.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/__main__.py b/__main__.py index 16b0f63..deacefa 100644 --- a/__main__.py +++ b/__main__.py @@ -1,15 +1,22 @@ -import os.path -from fastapi import FastAPI -from .datatemplates.agent_id import AgentId -from .modules import daemon -from .config import Config +from typing import Annotated + +from fastapi import FastAPI, Depends, Request +from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm app = FastAPI() +oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token") + + +@app.post("/token") +async def login(form_data: OAuth2PasswordRequestForm = Depends()): + user = form_data.username + return {"access_token": user, "token_type": "bearer"} + -@app.post("/tasks") -async def get_tasks(agent_id: AgentId): - return "foo" +@app.get("/{callsign}/tasks") +async def get_tasks(callsign: str, token: Annotated[str, Depends(oauth2_scheme)]): + return f'{{"callsign": "{callsign}", "token": "{token}"}}' # if __name__ == "__main__": # with open(os.path.join(os.path.dirname(__file__), Config.TOKEN_FILE_NAME)) as f: |