annot-server/webapp/api.py
author rougeronj
Thu, 22 Jan 2015 10:30:36 +0100
changeset 114 9fcb0e0991ed
parent 108 082b64a5c699
permissions -rw-r--r--
Add 1 hour to annot timsetamp to catch up the current time
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)
108
082b64a5c699 add vizualizations to server
ymh <ymh.work@gmail.com>
parents: 26
diff changeset
    21
082b64a5c699 add vizualizations to server
ymh <ymh.work@gmail.com>
parents: 26
diff changeset
    22
manager.create_api(models.EventSession,
082b64a5c699 add vizualizations to server
ymh <ymh.work@gmail.com>
parents: 26
diff changeset
    23
    methods=['GET'],
082b64a5c699 add vizualizations to server
ymh <ymh.work@gmail.com>
parents: 26
diff changeset
    24
    url_prefix='/api/v1',
082b64a5c699 add vizualizations to server
ymh <ymh.work@gmail.com>
parents: 26
diff changeset
    25
    primary_key='uuid',
082b64a5c699 add vizualizations to server
ymh <ymh.work@gmail.com>
parents: 26
diff changeset
    26
    max_results_per_page=sys.maxint)
082b64a5c699 add vizualizations to server
ymh <ymh.work@gmail.com>
parents: 26
diff changeset
    27
082b64a5c699 add vizualizations to server
ymh <ymh.work@gmail.com>
parents: 26
diff changeset
    28
manager.create_api(models.Event,
082b64a5c699 add vizualizations to server
ymh <ymh.work@gmail.com>
parents: 26
diff changeset
    29
    methods=['GET'],
082b64a5c699 add vizualizations to server
ymh <ymh.work@gmail.com>
parents: 26
diff changeset
    30
    url_prefix='/api/v1',
082b64a5c699 add vizualizations to server
ymh <ymh.work@gmail.com>
parents: 26
diff changeset
    31
    primary_key='code',
082b64a5c699 add vizualizations to server
ymh <ymh.work@gmail.com>
parents: 26
diff changeset
    32
    max_results_per_page=sys.maxint)