annot-server/webapp/api.py
author rougeronj
Thu, 22 Jan 2015 09:26:43 +0100
changeset 111 a7b72620d227
parent 26 ebfd0d3cffab
child 108 082b64a5c699
permissions -rw-r--r--
Add variable "wait". When this variable set, the annotsroll wait ignore some annotations, and wait before printing an otherone so there is no superposition. Can be passed as an options
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)