|
|
import os |
|
|
import json |
|
|
import uvicorn |
|
|
from fastapi import FastAPI |
|
|
from fastapi.staticfiles import StaticFiles |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DATA_DIR = "data" |
|
|
OUTPUT_FILE = "filelist.json" |
|
|
|
|
|
def generate_file_list(): |
|
|
"""Scans the data directory and creates a fresh filelist.json.""" |
|
|
print("--- Running automatic file scan ---") |
|
|
if not os.path.exists(DATA_DIR): |
|
|
print(f"Warning: The '{DATA_DIR}' directory was not found. Creating an empty list.") |
|
|
filenames = [] |
|
|
else: |
|
|
filenames = [f for f in os.listdir(DATA_DIR) if f.endswith(".html")] |
|
|
|
|
|
|
|
|
|
|
|
with open(OUTPUT_FILE, 'w') as f: |
|
|
json.dump(filenames, f) |
|
|
|
|
|
print(f"Successfully created '{OUTPUT_FILE}' with {len(filenames)} files.") |
|
|
|
|
|
|
|
|
generate_file_list() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app = FastAPI() |
|
|
|
|
|
|
|
|
|
|
|
app.mount("/", StaticFiles(directory=".", html=True), name="static") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
|
|
|
|
|
|
|
|
uvicorn.run(app, host="0.0.0.0", port=7860) |