You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
653 B
21 lines
653 B
from flask.blueprints import Blueprint
|
|
from flask.helpers import url_for
|
|
from werkzeug.utils import redirect
|
|
|
|
api = Blueprint('api', __name__)
|
|
api_docs = {}
|
|
api_docs_missing = []
|
|
|
|
def addApiView(route, func, static = False, docs = None, **kwargs):
|
|
api.add_url_rule(route + ('' if static else '/'), endpoint = route.replace('.', '::') if route else 'index', view_func = func, **kwargs)
|
|
if docs:
|
|
api_docs[route[4:] if route[0:4] == 'api.' else route] = docs
|
|
else:
|
|
api_docs_missing.append(route)
|
|
|
|
""" Api view """
|
|
def index():
|
|
index_url = url_for('web.index')
|
|
return redirect(index_url + 'docs/')
|
|
|
|
addApiView('', index)
|
|
|