Spaces:
Paused
Paused
Rename server.py to server.txt
Browse files- server.py +0 -37
- server.txt +12 -0
server.py
DELETED
|
@@ -1,37 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import uvicorn
|
| 3 |
-
from fastapi import FastAPI
|
| 4 |
-
from datetime import datetime, timedelta
|
| 5 |
-
|
| 6 |
-
app = FastAPI(docs_url=None, redoc_url="/")
|
| 7 |
-
|
| 8 |
-
# Store startup time
|
| 9 |
-
START_TIME = datetime.utcnow()
|
| 10 |
-
|
| 11 |
-
@app.get("/status")
|
| 12 |
-
def status():
|
| 13 |
-
return {"message": "running"}
|
| 14 |
-
|
| 15 |
-
@app.get("/ping")
|
| 16 |
-
def ping():
|
| 17 |
-
now = datetime.utcnow()
|
| 18 |
-
uptime_duration = now - START_TIME
|
| 19 |
-
days = uptime_duration.days
|
| 20 |
-
hours, remainder = divmod(uptime_duration.seconds, 3600)
|
| 21 |
-
minutes, _ = divmod(remainder, 60)
|
| 22 |
-
|
| 23 |
-
parts = []
|
| 24 |
-
if days:
|
| 25 |
-
parts.append(f"{days} day{'s' if days != 1 else ''}")
|
| 26 |
-
if hours:
|
| 27 |
-
parts.append(f"{hours} hour{'s' if hours != 1 else ''}")
|
| 28 |
-
if minutes:
|
| 29 |
-
parts.append(f"{minutes} minute{'s' if minutes != 1 else ''}")
|
| 30 |
-
|
| 31 |
-
return {
|
| 32 |
-
"status": "xd!",
|
| 33 |
-
"uptime": ", ".join(parts) or "just started"
|
| 34 |
-
}
|
| 35 |
-
|
| 36 |
-
if __name__ == "__main__":
|
| 37 |
-
uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
server.txt
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import uvicorn
|
| 3 |
+
from fastapi import FastAPI
|
| 4 |
+
|
| 5 |
+
app = FastAPI(docs_url=None, redoc_url="/")
|
| 6 |
+
|
| 7 |
+
@app.get("/status")
|
| 8 |
+
def hello():
|
| 9 |
+
return {"message": "running"}
|
| 10 |
+
|
| 11 |
+
if __name__ == "__main__":
|
| 12 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|