Hello fellow PythonAnywhere support members, I am currently building a website using your platform combining Next.js + Flask. To store data from the website I use the onboard MySQL server provided by you guys, but it's been causing me a little bit of trouble over the past couple of days.
It hangs up on me all the sudden after not making requests for an estimated time period of atleast five minutes... When you look at it from a resource POV, that's great and all, but when a user would want to do an action, the server wouldn't respond.
I also have a piece of code to catch a situation like this and the code does infact return maintenacne, when I refresh my app again, it's all good.
@app.before_request
def is_database_online():
if request.method == "POST" or request.method == "GET":
try:
db.create_all()
session['MAINTENANCE'] = "NO"
if request.path == "/":
return {"MAINTENANCE":False}
except:
traceback.print_exc()
if "MAINTENANCE" in session.keys() and session['MAINTENANCE'] == "TRUE":
return {"MAINTENANCE":"ON-GOING"}
else:
session["MAINTENANCE"] = "TRUE"
return {"MAINTENANCE":True}
Thanks in advance for any help or clarification, Niv.