Example #1
0
#!/usr/bin/env python
import sys

from swic.app import app, api
from swic.utils import get_subclasses, excepthook
from swic.database import get_store
from swic.decorators import rest
from swic.models import Event
from swic.api.base import BaseResource

# Register all REST endpoints
for cls in get_subclasses('swic/api', BaseResource):
    if cls.route is not None:
        api.add_resource(rest(cls), cls.route)

# Register the Server-Restart Event
with get_store() as store:
    store.add(Event('SERVER_RESTARTED'))


if __name__ == "__main__":
    sys.excepthook = excepthook
    app.run("0.0.0.0")
Example #2
0
def before_request():
    g.store = get_store()