summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--__main__.py21
-rw-r--r--config.py6
-rw-r--r--requirements.txt1
4 files changed, 28 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index 3aeb0d7..fd39922 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,8 @@
.idea/
-sta.token
+database/
+
spacetraders-sdk/
modules/spacetraders
+
__pycache__/
venv/
diff --git a/__main__.py b/__main__.py
index deacefa..7ae3047 100644
--- a/__main__.py
+++ b/__main__.py
@@ -1,9 +1,28 @@
+import os.path
+import sqlite3
+from pathlib import Path
+
+from contextlib import asynccontextmanager
from typing import Annotated
from fastapi import FastAPI, Depends, Request
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
-app = FastAPI()
+from .config import Config
+
+
+sq_con = None
+
+@asynccontextmanager
+async def lifespan(app: FastAPI):
+ db_dir = os.path.dirname(Config.DATABASE_PATH)
+ Path(db_dir).mkdir(parents=True, exist_ok=True)
+
+ sq_con = sqlite3.connect(Config.DATABASE_PATH)
+ yield
+
+
+app = FastAPI(lifespan=lifespan)
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
diff --git a/config.py b/config.py
index 87c9872..cf5e0a5 100644
--- a/config.py
+++ b/config.py
@@ -1,3 +1,5 @@
+import os.path
+
+
class Config:
- AGENT_SYMBOL = 'WAZUL'
- TOKEN_FILE_NAME = 'sta.token'
+ DATABASE_PATH = os.path.join(os.path.dirname(__file__), "database/database.db")
diff --git a/requirements.txt b/requirements.txt
index 13712cc..7833938 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1 +1,2 @@
fastapi[standard]
+passlib[bcrypt]