Exemplo n.º 1
0
    # 'middleware.authRequest.AuthRequest',
    'middleware.registerRequest.RegisterRequest',
    'middleware.cors.CORSRequest',

)


def applyMiddleware(app):
    modules = [('.'.join(module.split('.')[:-1]),
                '.'.join(module.split('.')[-1:])) for module in middleware]
    for module, f in modules:
        module = __import__(module, fromlist=[f])
        app = getattr(module, f)(app)
    return app


hello_world = Router()

hello_world.add_route('/hello/{name:\w*}', controller=Hello)

hello_world = applyMiddleware(hello_world)

if __name__ == '__main__':
    import doctest
    from wsgiref.simple_server import make_server

    doctest.testmod()
    print('serving')
    server = make_server('127.0.0.1', 8080, hello_world)
    server.serve_forever()
Exemplo n.º 2
0
middleware = (
    # 'middleware.authRequest.AuthRequest',
    'middleware.registerRequest.RegisterRequest',
    'middleware.cors.CORSRequest',
)


def applyMiddleware(app):
    modules = [('.'.join(module.split('.')[:-1]),
                '.'.join(module.split('.')[-1:])) for module in middleware]
    for module, f in modules:
        module = __import__(module, fromlist=[f])
        app = getattr(module, f)(app)
    return app


hello_world = Router()

hello_world.add_route('/hello/{name:\w*}', controller=Hello)

hello_world = applyMiddleware(hello_world)

if __name__ == '__main__':
    import doctest
    from wsgiref.simple_server import make_server

    doctest.testmod()
    print('serving')
    server = make_server('127.0.0.1', 8080, hello_world)
    server.serve_forever()
Exemplo n.º 3
0
from core import Response
from core.router import Router
from core.template import render


def hello(request, name=None):
    return render('index.html', {})


routes = Router()
routes.add_route(r'/$', hello)
Exemplo n.º 4
0
from core.router import Router
from server.apps.comments.views import IndexView, CommentAddView, StatisticView, CommentView, RegionView, DeleteComment

router = Router(__file__)

router.add_route(r'^/$', IndexView())
router.add_route(r'^/index$', IndexView())
router.add_route(r'^/comment$', CommentAddView())
router.add_route(r'^/stat$', StatisticView())
router.add_route(r'^/stat?id=\d*', StatisticView())
router.add_route(r'^/view$', CommentView())
router.add_route(r'^/comment/delete$', DeleteComment())
router.add_route(r'^/region$', RegionView())