Private GIT
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CouchPotatoServer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vlbox
CouchPotatoServer
Commits
b936576d
Commit
b936576d
authored
Apr 25, 2012
by
Ruud
Browse files
Options
Downloads
Patches
Plain Diff
Get apikey with username and password. closes #142
parent
ac15df31
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
couchpotato/__init__.py
+18
-0
18 additions, 0 deletions
couchpotato/__init__.py
couchpotato/templates/api.html
+6
-0
6 additions, 0 deletions
couchpotato/templates/api.html
with
24 additions
and
0 deletions
couchpotato/__init__.py
+
18
−
0
View file @
b936576d
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.helpers.request
import
getParams
,
jsonified
from
couchpotato.core.helpers.variable
import
md5
from
couchpotato.core.logger
import
CPLog
from
couchpotato.environment
import
Env
from
flask.app
import
Flask
...
...
@@ -51,6 +53,22 @@ def apiDocs():
del
api_docs_missing
[
''
]
return
render_template
(
'
api.html
'
,
fireEvent
=
fireEvent
,
routes
=
sorted
(
routes
),
api_docs
=
api_docs
,
api_docs_missing
=
sorted
(
api_docs_missing
))
@web.route
(
'
getkey/
'
)
def
getApiKey
():
api
=
None
params
=
getParams
()
username
=
Env
.
setting
(
'
username
'
)
password
=
Env
.
setting
(
'
password
'
)
if
(
params
.
get
(
'
u
'
)
==
md5
(
username
)
or
not
username
)
and
(
params
.
get
(
'
p
'
)
==
password
or
not
password
):
api
=
Env
.
setting
(
'
api_key
'
)
return
jsonified
({
'
success
'
:
api
is
not
None
,
'
api_key
'
:
api
})
@app.errorhandler
(
404
)
def
page_not_found
(
error
):
index_url
=
url_for
(
'
web.index
'
)
...
...
This diff is collapsed.
Click to expand it.
couchpotato/templates/api.html
+
6
−
0
View file @
b936576d
...
...
@@ -18,6 +18,12 @@
<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>
<br
/>
<br
/>
Get the API key:
<pre><a
href=
"/getkey/?p=md5(password)&u=md5(username)"
>
/getkey/?p=md5(password)
&
u=md5(username)
</a></pre>
Will return {"api_key": "XXXXXXXXXX", "success": true}. When username or password is empty you don't need to md5 it.
<br
/>
</div>
{% for route in routes %}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment