add 405 handler
This commit is contained in:
@@ -149,6 +149,13 @@ def clear_stale_sessions():
|
||||
for sess in stale_sessions:
|
||||
sess.delete()
|
||||
|
||||
def clear_api_limits():
|
||||
from .db import db
|
||||
from .models import APIRateLimits
|
||||
with db.transaction():
|
||||
limits = APIRateLimits.select()
|
||||
for l in limits:
|
||||
l.delete()
|
||||
|
||||
cache = Cache()
|
||||
|
||||
@@ -223,6 +230,7 @@ def create_app():
|
||||
create_deleted_user()
|
||||
|
||||
clear_stale_sessions()
|
||||
clear_api_limits()
|
||||
|
||||
reparse_babycode()
|
||||
|
||||
@@ -320,6 +328,15 @@ def create_app():
|
||||
else:
|
||||
return render_template('common/404.html'), e.code
|
||||
|
||||
@app.errorhandler(405)
|
||||
def _handle_405(e):
|
||||
if request.path.startswith('/hyperapi/'):
|
||||
return '<h1>method not allowed</h1>', e.code
|
||||
elif request.path.startswith('/api/'):
|
||||
return {'error': 'method not allowed'}, e.code
|
||||
else:
|
||||
return render_template('common/404.html'), e.code
|
||||
|
||||
@app.errorhandler(403)
|
||||
def _handle_403(e):
|
||||
if request.path.startswith('/hyperapi/'):
|
||||
|
||||
Reference in New Issue
Block a user