Merge branch 'feature/info'
This commit is contained in:
commit
c9c0df229a
@ -60,7 +60,7 @@ from werkzeug.contrib.fixers import ProxyFix
|
||||
local = Local()
|
||||
local_manager = LocalManager([local])
|
||||
|
||||
from isso import db, migrate, wsgi, ext
|
||||
from isso import db, migrate, wsgi, ext, views
|
||||
from isso.core import ThreadedMixin, uWSGIMixin, Config
|
||||
from isso.utils import parse, http, JSONRequest, origin
|
||||
from isso.views import comments
|
||||
@ -96,7 +96,9 @@ class Isso(object):
|
||||
self.signal = ext.Signal(*subscribers)
|
||||
|
||||
self.urls = Map()
|
||||
self.api = comments.API(self)
|
||||
|
||||
views.Info(self)
|
||||
comments.API(self)
|
||||
|
||||
def sign(self, obj):
|
||||
return self.signer.dumps(obj)
|
||||
|
@ -1,7 +1,19 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import pkg_resources
|
||||
dist = pkg_resources.get_distribution("isso")
|
||||
|
||||
import json
|
||||
|
||||
from werkzeug.wrappers import Response
|
||||
from werkzeug.routing import Rule
|
||||
from werkzeug.exceptions import BadRequest
|
||||
|
||||
from isso import local
|
||||
from isso.compat import text_type as str
|
||||
|
||||
|
||||
class requires:
|
||||
"""Verify that the request URL contains and can parse the parameter.
|
||||
@ -33,3 +45,21 @@ class requires:
|
||||
return func(cls, env, req, *args, **kwargs)
|
||||
|
||||
return dec
|
||||
|
||||
|
||||
class Info(object):
|
||||
|
||||
def __init__(self, isso):
|
||||
self.moderation = isso.conf.getboolean("moderation", "enabled")
|
||||
isso.urls.add(Rule('/info', endpoint=self.show))
|
||||
|
||||
def show(self, environ, request):
|
||||
|
||||
rv = {
|
||||
"version": dist.version,
|
||||
"host": str(local("host")),
|
||||
"origin": str(local("origin")),
|
||||
"moderation": self.moderation,
|
||||
}
|
||||
|
||||
return Response(json.dumps(rv), 200, content_type="application/json")
|
||||
|
Loading…
Reference in New Issue
Block a user