Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import subprocess
|
2 |
import logging
|
3 |
-
from fastapi import FastAPI
|
4 |
from fastapi.responses import HTMLResponse
|
5 |
app = FastAPI()
|
6 |
|
@@ -16,27 +16,4 @@ def welcome():
|
|
16 |
<a href="https://github.com/Mihaiii/TimeStampBuddy" target="_blank" rel="noopener noreferrer">GitHub Repository</a>.
|
17 |
</p>
|
18 |
</div>
|
19 |
-
"""
|
20 |
-
|
21 |
-
@app.post("/set_log_level")
|
22 |
-
async def set_log_level(request: Request):
|
23 |
-
try:
|
24 |
-
body = await request.json()
|
25 |
-
level = body.get("level", "").upper()
|
26 |
-
|
27 |
-
if level in ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']:
|
28 |
-
logger = logging.getLogger()
|
29 |
-
logger.setLevel(level)
|
30 |
-
|
31 |
-
for logger_name in logging.root.manager.loggerDict:
|
32 |
-
logging.getLogger(logger_name).setLevel(level)
|
33 |
-
|
34 |
-
for handler in logger.handlers:
|
35 |
-
handler.setLevel(level)
|
36 |
-
|
37 |
-
|
38 |
-
return {"message": f"Log level changed to {level}"}
|
39 |
-
|
40 |
-
raise HTTPException(status_code=400, detail="Invalid log level")
|
41 |
-
except Exception as e:
|
42 |
-
raise HTTPException(status_code=500, detail=str(e))
|
|
|
1 |
import subprocess
|
2 |
import logging
|
3 |
+
from fastapi import FastAPI
|
4 |
from fastapi.responses import HTMLResponse
|
5 |
app = FastAPI()
|
6 |
|
|
|
16 |
<a href="https://github.com/Mihaiii/TimeStampBuddy" target="_blank" rel="noopener noreferrer">GitHub Repository</a>.
|
17 |
</p>
|
18 |
</div>
|
19 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|