fd
This commit is contained in:
parent
9b68b619d3
commit
3acec6c7fc
8 changed files with 1084 additions and 212 deletions
|
@ -211,48 +211,4 @@ def validate_formkey(f):
|
|||
return f(*args, v=v, **kwargs)
|
||||
|
||||
wrapper.__name__ = f.__name__
|
||||
return wrapper
|
||||
|
||||
def api(*scopes, no_ban=False):
|
||||
|
||||
def wrapper_maker(f):
|
||||
|
||||
def wrapper(*args, **kwargs):
|
||||
|
||||
if request.path.startswith(('/api/v1','/api/v2')):
|
||||
|
||||
v = kwargs.get('v')
|
||||
|
||||
result = f(*args, **kwargs)
|
||||
|
||||
if isinstance(result, dict):
|
||||
resp = result['api']()
|
||||
else:
|
||||
resp = result
|
||||
|
||||
if not isinstance(resp, RespObj):
|
||||
resp = make_response(resp)
|
||||
|
||||
return resp
|
||||
|
||||
else:
|
||||
|
||||
result = f(*args, **kwargs)
|
||||
|
||||
if not isinstance(result, dict):
|
||||
return result
|
||||
|
||||
try:
|
||||
if request.path.startswith('/inpage/'):
|
||||
return result['inpage']()
|
||||
elif request.path.startswith(('/api/vue/','/test/')):
|
||||
return result['api']()
|
||||
else:
|
||||
return result['html']()
|
||||
except KeyError:
|
||||
return result
|
||||
|
||||
wrapper.__name__ = f.__name__
|
||||
return wrapper
|
||||
|
||||
return wrapper_maker
|
||||
return wrapper
|
Loading…
Add table
Add a link
Reference in a new issue