summaryrefslogtreecommitdiff
path: root/archivist/server.py
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2017-10-03 22:02:16 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2017-10-03 22:06:16 +0200
commit90a209e69f455b49c4a642fb2b3288f915fed1dc (patch)
tree704e46827a82d60faf413b1ef992c82619b3bfa6 /archivist/server.py
parentd012b1b3160e651b32d7e822ca998a2860828081 (diff)
downloadarchivist-90a209e69f455b49c4a642fb2b3288f915fed1dc.tar.gz
archivist-90a209e69f455b49c4a642fb2b3288f915fed1dc.tar.bz2
archivist-90a209e69f455b49c4a642fb2b3288f915fed1dc.zip
Basic server implementation
Diffstat (limited to '')
-rw-r--r--archivist/server.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/archivist/server.py b/archivist/server.py
new file mode 100644
index 0000000..8500af0
--- /dev/null
+++ b/archivist/server.py
@@ -0,0 +1,31 @@
+import click
+from flask.cli import FlaskGroup, ScriptInfo
+from flask import Flask
+from flask_restful import Api, Resource, marshal_with, marshal_with_field, fields
+
+from . import model as m
+
+class Tag(Resource):
+ tag_fields = {
+ 'name' : fields.String,
+ 'prefix' : fields.String
+ }
+
+class TagList(Resource):
+ tag_list = { fields.List(fields.Nested(Tag.tag_fields)) }
+
+ @marshal_with_field(fields.List(fields.Nested(Tag.tag_fields)))
+ def get(self):
+ res = list(m.Tag.select().where(~m.Tag.default).dicts().iterator())
+ print(res)
+ return res
+
+def create_app(info):
+ app = Flask('archivist')
+ api = Api(app)
+ api.add_resource(TagList, '/')
+ return app
+
+server_group = FlaskGroup(
+ name='server',
+ context_settings = {'obj' : ScriptInfo(create_app=create_app)})