Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions app/api/products.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions app/api/root.py
Original file line number Diff line number Diff line change
@@ -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__

Expand All @@ -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"}
]
Expand Down
14 changes: 14 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Loading