API introduction
This commit is contained in:
@@ -49,7 +49,7 @@ def apiDocs():
|
||||
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))
|
||||
return render_template('api.html', fireEvent = fireEvent, routes = sorted(routes), api_docs = api_docs, api_docs_missing = sorted(api_docs_missing))
|
||||
|
||||
@app.errorhandler(404)
|
||||
def page_not_found(error):
|
||||
|
||||
@@ -70,7 +70,7 @@ def jsonify(mimetype, *args, **kwargs):
|
||||
|
||||
def jsonified(*args, **kwargs):
|
||||
from couchpotato.environment import Env
|
||||
callback = getParam('json_callback', None)
|
||||
callback = getParam('callback_func', None)
|
||||
if callback:
|
||||
return padded_jsonify(callback, *args, **kwargs)
|
||||
else:
|
||||
|
||||
@@ -11,7 +11,7 @@ var ApiClass = new Class({
|
||||
|
||||
var r_type = self.options.is_remote ? 'JSONP' : 'JSON';
|
||||
return new Request[r_type](Object.merge({
|
||||
'callbackKey': 'json_callback',
|
||||
'callbackKey': 'callback_func',
|
||||
'method': 'get',
|
||||
'url': self.createUrl(type),
|
||||
}, options)).send()
|
||||
|
||||
@@ -7,6 +7,19 @@
|
||||
<body>
|
||||
|
||||
<h1>CouchPotato API Documentation</h1>
|
||||
<div class="api">
|
||||
You can access the API via <pre>{{ fireEvent('app.api_url', single = True)|safe }}/</pre>
|
||||
To see it in action, have a look at the webinterface with Firebug (on firefox) or the development tools included in Chrome.
|
||||
All the data that you see there are from the API.
|
||||
<br />
|
||||
<br />
|
||||
A normal API call:
|
||||
<pre><a href="{{ fireEvent('app.api_url', single = True)|safe }}/updater.info/">{{ fireEvent('app.api_url', single = True)|safe }}/updater.info/</a></pre>
|
||||
<br />
|
||||
You can also use the API over another domain using JSONP, the callback function should be in 'callback_func'
|
||||
<pre><a href="{{ fireEvent('app.api_url', single = True)|safe }}/updater.info/?callback_func=myfunction">{{ fireEvent('app.api_url', single = True)|safe }}/updater.info/?callback_func=myfunction</a></pre>
|
||||
</div>
|
||||
|
||||
{% for route in routes %}
|
||||
{% if api_docs.get(route) %}
|
||||
<div class="api">
|
||||
|
||||
Reference in New Issue
Block a user