From 24f09a856e0844a2aaadeadf884e2244404fd726 Mon Sep 17 00:00:00 2001 From: Goldlabel Apps Ltd Date: Fri, 20 Mar 2026 21:08:54 +0000 Subject: [PATCH 1/2] Add docs endpoint; remove psycopg2 import Remove unused psycopg2 import, add a /docs entry to the root endpoints list, and include base_url in the response meta (removing the duplicated base_url key). Small cleanup to tidy imports and expose the documentation URL from the API root. --- app/api/root.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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"} ] From afc262c7d3fdb9eed3b22699a7bb960c8ad39ce5 Mon Sep 17 00:00:00 2001 From: Goldlabel Apps Ltd Date: Sun, 22 Mar 2026 08:21:10 +0000 Subject: [PATCH 2/2] Add static assets, favicon, and base_url meta Mount static files and serve a favicon in FastAPI, add BASE_URL to API metadata, and update README run command. main.py: import StaticFiles/FileResponse/os, mount /static to app/static and add a /favicon.ico route. app/api/products.py: load dotenv and include base_url (from BASE_URL env, default http://localhost:8000) in the response meta. README.md: show the uvicorn start command with --reload in a shell code block for local development. --- README.md | 6 +++--- app/api/products.py | 5 +++++ app/main.py | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) 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/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)