changeset 19:0d32e35d251d

basic api views
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Sun, 02 Jun 2013 11:32:01 +0200
parents ab19211ebe1a
children 44d561c15361
files requirements.txt server/__init__.py server/api.py
diffstat 3 files changed, 35 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/requirements.txt	Sun Jun 02 11:32:01 2013 +0200
@@ -0,0 +1,4 @@
+flask
+numpy
+scipy
+flask-classy
--- a/server/__init__.py	Sun Jun 02 11:08:40 2013 +0200
+++ b/server/__init__.py	Sun Jun 02 11:32:01 2013 +0200
@@ -11,6 +11,9 @@
     app.config.from_envvar('PARTYBUDDY_SETTINGS')
 
 
+from . import api
+
+
 @app.route('/')
 def home():
     return flask.render_template('index.html')
--- a/server/api.py	Sun Jun 02 11:08:40 2013 +0200
+++ b/server/api.py	Sun Jun 02 11:32:01 2013 +0200
@@ -1,9 +1,34 @@
+import flask
+from flask.ext.classy import FlaskView
+
 from . import app
-from flask.ext.classy import FlaskView
+
+
+def register(*args, **kwargs):
+    """A convenience decorator for registering class views."""
+
+    def decorator(cls):
+        cls.register(*args, **kwargs)
+        return cls
+    return decorator
 
 
+@register(app)
+class UsersView(FlaskView):
+    def index(self):
+        return flask.jsonify({
+            'users': [],
+        })
+
+    def get(self, email):
+        return flask.jsonify({
+            'email': email,
+        })
+
+@register(app)
 class PartyTraceView(FlaskView):
     def index(self):
-        return '42'
+        return flask.jsonify({
+            'trace': [],
+        })
 
-PartyTraceView.register(app)