annot-server/webapp/api.py
author cavaliet
Sat, 25 Oct 2014 11:54:11 +0200
changeset 68 9f6b2da245a3
parent 26 ebfd0d3cffab
child 108 082b64a5c699
permissions -rw-r--r--
new cats
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
26
ebfd0d3cffab Correction on export_annotation. First working version
ymh <ymh.work@gmail.com>
parents: 24
diff changeset
     6
import sys
ebfd0d3cffab Correction on export_annotation. First working version
ymh <ymh.work@gmail.com>
parents: 24
diff changeset
     7
24
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
import flask.ext.restless
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
import database
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
import models
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
from webapp import app
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 = 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
    15
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
manager.create_api(models.Annotation,
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
    methods=['GET', 'POST', 'PUT', 'DELETE'],
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
    url_prefix='/api/v1',
eb1f7b06001f add api + first version (not tested) of export annotation script
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
    primary_key='uuid',
26
ebfd0d3cffab Correction on export_annotation. First working version
ymh <ymh.work@gmail.com>
parents: 24
diff changeset
    20
    max_results_per_page=sys.maxint)