From faef640e7829d97bd8c2653c57b4d1d3680efd5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Fri, 26 Sep 2025 09:34:30 +0200 Subject: [PATCH] added key file creation --- api/main.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/api/main.py b/api/main.py index c2dce34..a81eaf0 100644 --- a/api/main.py +++ b/api/main.py @@ -1,14 +1,26 @@ + import sqlite3 import random from fastapi import FastAPI, HTTPException, Depends from typing import List, Optional from threading import Lock from datetime import datetime, timedelta +import os + app = FastAPI() DB_PATH = './database/schloter.API.db' lock = Lock() +# Create allowed_tokens.txt with example keys if it doesn't exist +def ensure_allowed_tokens_file(path='allowed_tokens.txt'): + if not os.path.exists(path): + with open(path, 'w') as f: + f.write('examplekey1\nexamplekey2\n') + print(f"Created {path} with example keys.") + +ensure_allowed_tokens_file('allowed_tokens.txt') + # Database initialization def init_db(): import os