Upload 4 files
Browse files- Dockerfile +16 -0
- app.py +14 -0
- auth.py +37 -0
- requirements.txt +9 -0
Dockerfile
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
| 2 |
+
# you will also find guides on how best to write your Dockerfile
|
| 3 |
+
|
| 4 |
+
FROM python:3.13
|
| 5 |
+
|
| 6 |
+
RUN useradd -m -u 1000 user
|
| 7 |
+
USER user
|
| 8 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
| 9 |
+
|
| 10 |
+
WORKDIR /app
|
| 11 |
+
|
| 12 |
+
COPY --chown=user ./requirements.txt requirements.txt
|
| 13 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 14 |
+
|
| 15 |
+
COPY --chown=user . /app
|
| 16 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
app.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from routers import gemini, finance, mistral, cnn, powerpoint
|
| 3 |
+
|
| 4 |
+
app = FastAPI(title="STX DEV API")
|
| 5 |
+
|
| 6 |
+
@app.get("/")
|
| 7 |
+
def hello():
|
| 8 |
+
return {"message": "Hello World!"}
|
| 9 |
+
|
| 10 |
+
app.include_router(gemini.router)
|
| 11 |
+
app.include_router(finance.router)
|
| 12 |
+
app.include_router(mistral.router)
|
| 13 |
+
app.include_router(cnn.router)
|
| 14 |
+
app.include_router(powerpoint.router)
|
auth.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import HTTPException, Depends
|
| 2 |
+
from fastapi.security import APIKeyQuery
|
| 3 |
+
from typing import Annotated, Optional
|
| 4 |
+
import os
|
| 5 |
+
import uuid
|
| 6 |
+
|
| 7 |
+
AUTH_TOKEN = os.getenv("AUTH_TOKEN")
|
| 8 |
+
api_key_query = APIKeyQuery(name="token", auto_error=False)
|
| 9 |
+
|
| 10 |
+
async def verify_token(token: Annotated[str, Optional[str], Depends(api_key_query)]):
|
| 11 |
+
if not AUTH_TOKEN:
|
| 12 |
+
raise HTTPException(
|
| 13 |
+
status_code=500,
|
| 14 |
+
detail="AUTH_TOKEN not configured on server"
|
| 15 |
+
)
|
| 16 |
+
|
| 17 |
+
if not token:
|
| 18 |
+
raise HTTPException(
|
| 19 |
+
status_code=401,
|
| 20 |
+
detail="Token is required"
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
try:
|
| 24 |
+
uuid.UUID(token)
|
| 25 |
+
except ValueError:
|
| 26 |
+
raise HTTPException(
|
| 27 |
+
status_code=400,
|
| 28 |
+
detail="Invalid token format. Token must be a valid UUID"
|
| 29 |
+
)
|
| 30 |
+
|
| 31 |
+
if token != AUTH_TOKEN:
|
| 32 |
+
raise HTTPException(
|
| 33 |
+
status_code=401,
|
| 34 |
+
detail="Invalid token"
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
return token
|
requirements.txt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi
|
| 2 |
+
uvicorn[standard]
|
| 3 |
+
pydantic
|
| 4 |
+
mistralai
|
| 5 |
+
google-genai
|
| 6 |
+
httpx
|
| 7 |
+
python-multipart
|
| 8 |
+
yfinance
|
| 9 |
+
python-pptx
|