diff --git a/README.md b/README.md index fea5a33..501f854 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ > FastAPI/Python/Postgres/tsvector. Open Source, production ready Python FastAPI/Postgres app for [NX](https://goldlabel.pro?s=python-nx-ai) -#### Use - -`uvicorn app.main:app` +```sh +uvicorn app.main:app --reload +``` #### Install diff --git a/app/api/products.py b/app/api/products.py index 6c76b95..598265e 100644 --- a/app/api/products.py +++ b/app/api/products.py @@ -33,9 +33,14 @@ def root() -> dict: ] cur.close() conn.close() + + load_dotenv() + base_url = os.getenv("BASE_URL", "http://localhost:8000") + epoch = int(time.time() * 1000) meta = { "version": __version__, + "base_url": base_url, "time": time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()), "epoch": epoch, "severity": "success", diff --git a/app/api/root.py b/app/api/root.py index ef43167..c134924 100644 --- a/app/api/root.py +++ b/app/api/root.py @@ -1,7 +1,6 @@ from app import __version__ from fastapi import APIRouter import os, time -import psycopg2 from dotenv import load_dotenv from app import __version__ @@ -14,14 +13,15 @@ def root() -> dict: base_url = os.getenv("BASE_URL", "http://localhost:8000") epoch = int(time.time() * 1000) meta = { + "base_url": base_url, "version": __version__, "time": time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()), "epoch": epoch, "severity": "success", "message": f"NX AI says hello", - "base_url": base_url } endpoints = [ + {"docs": "docs", "url": f"{base_url}/docs"}, {"name": "health", "url": f"{base_url}/health"}, {"name": "products", "url": f"{base_url}/products"} ] diff --git a/app/main.py b/app/main.py index 5df8496..26bbb30 100644 --- a/app/main.py +++ b/app/main.py @@ -1,7 +1,11 @@ from app import __version__ """NX AI - FastAPI entry point.""" + from fastapi import FastAPI +from fastapi.staticfiles import StaticFiles +from fastapi.responses import FileResponse +import os from app import __version__ from app.api.routes import router @@ -12,4 +16,14 @@ version=__version__, ) + app.include_router(router) + +# Mount static directory +app.mount("/static", StaticFiles(directory=os.path.join(os.path.dirname(__file__), "static")), name="static") + +# Favicon route +@app.get("/favicon.ico", include_in_schema=False) +async def favicon(): + favicon_path = os.path.join(os.path.dirname(__file__), "static", "favicon.ico") + return FileResponse(favicon_path)