Spaces:
Paused
Paused
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,43 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
from fastapi.staticfiles import StaticFiles
|
| 3 |
-
from fastapi.middleware.cors import CORSMiddleware
|
| 4 |
-
from fastapi import Request
|
| 5 |
-
import os
|
| 6 |
-
|
| 7 |
-
# Create Gradio UI
|
| 8 |
-
with gr.Blocks(title="SkyData Game Server") as demo:
|
| 9 |
-
gr.Markdown("# 🌍 SkyData 3D Earth Game Server")
|
| 10 |
-
gr.Markdown("Server Status: **Online & Logging Active 🟢**")
|
| 11 |
-
|
| 12 |
-
app = demo.app
|
| 13 |
-
|
| 14 |
-
# Enable CORS for external requests
|
| 15 |
-
app.add_middleware(
|
| 16 |
-
CORSMiddleware,
|
| 17 |
-
allow_origins=["*"],
|
| 18 |
-
allow_credentials=True,
|
| 19 |
-
allow_methods=["*"],
|
| 20 |
-
allow_headers=["*"],
|
| 21 |
-
)
|
| 22 |
-
|
| 23 |
-
# Custom Logging Middleware to force print requests in Hugging Face Terminal
|
| 24 |
-
@app.middleware("http")
|
| 25 |
-
async def log_requests(request: Request, call_next):
|
| 26 |
-
path = request.url.path
|
| 27 |
-
if path.startswith("/country_flags") or path.startswith("/textures"):
|
| 28 |
-
print(f"📥 [HF SERVER LOG] Request: {path} | Client IP: {request.client.host}")
|
| 29 |
-
response = await call_next(request)
|
| 30 |
-
return response
|
| 31 |
-
|
| 32 |
-
# Mount country_flags directory
|
| 33 |
-
if os.path.exists("country_flags"):
|
| 34 |
-
app.mount("/country_flags", StaticFiles(directory="country_flags"), name="country_flags")
|
| 35 |
-
print("✅ [INIT] Mounted /country_flags folder successfully")
|
| 36 |
-
|
| 37 |
-
# Mount textures directory
|
| 38 |
-
if os.path.exists("textures"):
|
| 39 |
-
app.mount("/textures", StaticFiles(directory="textures"), name="textures")
|
| 40 |
-
print("✅ [INIT] Mounted /textures folder successfully")
|
| 41 |
-
|
| 42 |
-
if __name__ == "__main__":
|
| 43 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|