diff --git a/couchpotato/__init__.py b/couchpotato/__init__.py index 7058b111..f7dfb3a5 100644 --- a/couchpotato/__init__.py +++ b/couchpotato/__init__.py @@ -1,3 +1,4 @@ +from couchpotato.api import api_docs, api_docs_missing from couchpotato.core.auth import requires_auth from couchpotato.core.event import fireEvent from couchpotato.core.logger import CPLog @@ -35,6 +36,21 @@ def addView(route, func, static = False): def index(): return render_template('index.html', sep = os.sep, fireEvent = fireEvent, env = Env) +""" Api view """ +@web.route('docs/') +@requires_auth +def apiDocs(): + from couchpotato import app + routes = [] + for route, x in sorted(app.view_functions.iteritems()): + if route[0:4] == 'api.': + routes += [route[4:].replace('::', '.')] + + 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)) + @app.errorhandler(404) def page_not_found(error): index_url = url_for('web.index') diff --git a/couchpotato/api.py b/couchpotato/api.py index 77f24a56..71cf9b87 100644 --- a/couchpotato/api.py +++ b/couchpotato/api.py @@ -1,5 +1,7 @@ from flask.blueprints import Blueprint +from flask.helpers import url_for from flask.templating import render_template +from werkzeug.utils import redirect api = Blueprint('api', __name__) api_docs = {} @@ -14,17 +16,7 @@ def addApiView(route, func, static = False, docs = None): """ Api view """ def index(): - - from couchpotato import app - routes = [] - for route, x in sorted(app.view_functions.iteritems()): - if route[0:4] == 'api.': - routes += [route[4:].replace('::', '.')] - - 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)) + index_url = url_for('web.index') + return redirect(index_url + 'docs/') addApiView('', index) -addApiView('default', index) diff --git a/couchpotato/core/_base/_core/__init__.py b/couchpotato/core/_base/_core/__init__.py index 38631a2e..f48b157e 100644 --- a/couchpotato/core/_base/_core/__init__.py +++ b/couchpotato/core/_base/_core/__init__.py @@ -54,7 +54,7 @@ config = [{ 'name': 'api_key', 'default': uuid4().hex, 'readonly': 1, - 'description': "This is top-secret! Don't share this!", + 'description': 'Let 3rd party app do stuff. Docs', }, { 'name': 'debug',