Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -93,11 +93,10 @@
|
|
| 93 |
|
| 94 |
from fastapi import FastAPI
|
| 95 |
from fastapi.staticfiles import StaticFiles
|
| 96 |
-
from fastapi.responses import FileResponse
|
| 97 |
|
| 98 |
app = FastAPI()
|
| 99 |
|
| 100 |
-
# Mount the 'static' directory to serve static files.
|
| 101 |
# Assuming your static files are in a directory named 'static'.
|
| 102 |
app.mount("/static", StaticFiles(directory="static"), name="static")
|
| 103 |
|
|
@@ -108,4 +107,15 @@ def read_root():
|
|
| 108 |
|
| 109 |
@app.get("/api")
|
| 110 |
def read_api():
|
|
|
|
| 111 |
return {"message": "Hello from the FastAPI API!"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
from fastapi import FastAPI
|
| 95 |
from fastapi.staticfiles import StaticFiles
|
| 96 |
+
from fastapi.responses import FileResponse, JSONResponse
|
| 97 |
|
| 98 |
app = FastAPI()
|
| 99 |
|
|
|
|
| 100 |
# Assuming your static files are in a directory named 'static'.
|
| 101 |
app.mount("/static", StaticFiles(directory="static"), name="static")
|
| 102 |
|
|
|
|
| 107 |
|
| 108 |
@app.get("/api")
|
| 109 |
def read_api():
|
| 110 |
+
# This endpoint simply returns a JSON message.
|
| 111 |
return {"message": "Hello from the FastAPI API!"}
|
| 112 |
+
|
| 113 |
+
@app.get("/custom-auth")
|
| 114 |
+
def custom_auth():
|
| 115 |
+
# This is your custom authentication endpoint.
|
| 116 |
+
# Here, you should include your logic for authentication.
|
| 117 |
+
# For demonstration, it returns a JSON response with a token.
|
| 118 |
+
# token = "your_generated_token_here" # Placeholder token generation logic
|
| 119 |
+
token = create_jwt(cl.User(identifier="Test User"))
|
| 120 |
+
print("tokeeeeeee": token)
|
| 121 |
+
return JSONResponse({"token": token})
|