summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--__main__.py10
-rw-r--r--apirouters/agents.py2
-rw-r--r--modules/database.py2
3 files changed, 7 insertions, 7 deletions
diff --git a/__main__.py b/__main__.py
index 833bf72..9dba645 100644
--- a/__main__.py
+++ b/__main__.py
@@ -3,21 +3,21 @@ from typing import Annotated
from fastapi import FastAPI, Depends
-import apirouters.agents
-import modules.database
+from .apirouters import agents
+from .modules import database
@asynccontextmanager
async def lifespan(app: FastAPI):
- modules.database.cursor.execute(
+ database.cursor.execute(
"CREATE TABLE IF NOT EXISTS agents(primary_key INTEGER PRIMARY KEY, callsign TEXT NOT NULL UNIQUE, token_hash TEXT NOT NULL)")
yield
app = FastAPI(lifespan=lifespan)
-app.include_router(apirouters.agents.router)
+app.include_router(agents.router)
@app.get("/{callsign}/tasks")
-async def get_tasks(callsign: str, token: Annotated[str, Depends(apirouters.agents.oauth2_scheme)]):
+async def get_tasks(callsign: str, token: Annotated[str, Depends(agents.oauth2_scheme)]):
return f'{{"callsign": "{callsign}", "token": "{token}"}}'
diff --git a/apirouters/agents.py b/apirouters/agents.py
index b8c0b95..b16ab6d 100644
--- a/apirouters/agents.py
+++ b/apirouters/agents.py
@@ -5,7 +5,7 @@ from fastapi import APIRouter, Depends, Response
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
from passlib.context import CryptContext
-from modules.database import cursor, conn
+from ..modules.database import cursor, conn
router = APIRouter()
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
diff --git a/modules/database.py b/modules/database.py
index 9a7131c..577612c 100644
--- a/modules/database.py
+++ b/modules/database.py
@@ -1,7 +1,7 @@
import os.path
import sqlite3
from pathlib import Path
-from config import Config
+from ..config import Config
db_dir = os.path.dirname(Config.DATABASE_PATH)
Path(db_dir).mkdir(parents=True, exist_ok=True)