Spaces:
Sleeping
Sleeping
import subprocess | |
import logging | |
from fastapi import FastAPI | |
from fastapi.responses import HTMLResponse | |
app = FastAPI() | |
subprocess.Popen(["python3", "TimeStampBuddy/cron_processor.py"]) | |
def welcome(): | |
return """ | |
<div> | |
<h1>Hello!</h1> | |
<p>This service powers the <a href="https://x.com/TimeStampBuddy" target="_blank" rel="noopener noreferrer">@TimeStampBuddy</a>'s activity on Twitter.</p> | |
<p>For more details, visit | |
<a href="https://github.com/Mihaiii/TimeStampBuddy" target="_blank" rel="noopener noreferrer">GitHub Repository</a>. | |
</p> | |
</div> | |
""" | |
def set_log_level(): | |
try: | |
logger = logging.getLogger() | |
level = request.json.get('level', '').upper() | |
if level in ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL']: | |
logger.setLevel(level) | |
return f"Log level changed to {level}", 200 | |
return "Invalid log level", 400 | |
except Exception as e: | |
return str(e), 500 |