annot-server/webapp/api.py
author ymh <ymh.work@gmail.com>
Wed, 15 Oct 2014 13:09:47 +0200
changeset 24 eb1f7b06001f
child 26 ebfd0d3cffab
permissions -rw-r--r--
add api + first version (not tested) of export annotation script
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
#
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
# See LICENCE for detail
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
# Copyright (c) 2014 IRI
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
#
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
import flask.ext.restless
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
import database
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
import models
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
from webapp import app
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
manager = flask.ext.restless.APIManager(app, session=database.db_session)
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
manager.create_api(models.Annotation,
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
    methods=['GET', 'POST', 'PUT', 'DELETE'],
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
    url_prefix='/api/v1',
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
    primary_key='uuid',
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
    max_results_per_page=-1)