annot-server/webapp/__init__.py
author ymh <ymh.work@gmail.com>
Tue, 14 Oct 2014 05:07:37 +0200
changeset 22 986ee928a866
child 23 16a1925df2df
permissions -rw-r--r--
add sqlalchemy model + put create module for webapp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
#
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
# See LICENCE for detail
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
# Copyright (c) 2014 IRI
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
#
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
import uuid
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
import json
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
from flask import Flask
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
import config
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
import database
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
app = Flask(__name__)
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
app.secret_key = str(uuid.uuid4())
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
app.debug = config.DEBUG
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
app.config.from_object(config)
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
import webapp.views
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
@app.teardown_appcontext
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
def shutdown_session(exception=None):
986ee928a866 add sqlalchemy model + put create module for webapp
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
    database.db_session.remove()