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.

31 lines
968 B

14 years ago
from flask.blueprints import Blueprint
13 years ago
from flask.templating import render_template
14 years ago
api = Blueprint('api', __name__)
13 years ago
api_docs = {}
api_docs_missing = []
13 years ago
def addApiView(route, func, static = False, docs = None):
api.add_url_rule(route + ('' if static else '/'), endpoint = route.replace('.', '::') if route else 'index', view_func = func)
if docs:
api_docs[route[4:] if route[0:4] == 'api.' else route] = docs
else:
api_docs_missing.append(route)
14 years ago
""" Api view """
def index():
14 years ago
13 years ago
from couchpotato import app
14 years ago
routes = []
for route, x in sorted(app.view_functions.iteritems()):
if route[0:4] == 'api.':
13 years ago
routes += [route[4:].replace('::', '.')]
13 years ago
if api_docs.get(''):
del api_docs['']
del api_docs_missing['']
return render_template('api.html', routes = sorted(routes), api_docs = api_docs, api_docs_missing = sorted(api_docs_missing))
14 years ago
addApiView('', index)
addApiView('default', index)