TimeStampBuddy / app.py
Mihaiii's picture
Update app.py
999fa5d verified
raw
history blame
1.06 kB
import subprocess
import logging
from fastapi import FastAPI
from fastapi.responses import HTMLResponse
app = FastAPI()
subprocess.Popen(["python3", "TimeStampBuddy/cron_processor.py"])
@app.get("/", response_class=HTMLResponse)
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>
"""
@app.post('/set_log_level')
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