Exemplo n.º 1
0
    else:
        return tubes.Response("user not found", 404)

# return the generated requests javascript code on that url
# (on production you should save it to a file)
@handler.get('^/requests.js/?$', produces=tubes.JS)
def requests(request):
    '''return the requests.js file to interact with this API'''
    return tubes.Response(REQUESTS)

# return the generated model javascript code on that url
# (on production you should save it to a file)
@handler.get('^/model.js/?$', produces=tubes.JS)
def model(request):
    '''return the model.js file to interact with this API'''
    return MODEL

# show the API test page here
@handler.get('^/test.html/?$', produces=tubes.HTML)
def test(request):
    '''return a dummy html to play with the API'''
    return TEST_PAGE

REQUESTS = intertubes.generate_requests(handler)
MODEL = intertubes.generate_model([User])
TEST_PAGE = intertubes.generate_html_example(handler,
        ('/files/json2.js', '/model.js'))

if __name__ == '__main__':
    tubes.run(handler, use_reloader=True)
Exemplo n.º 2
0
Arquivo: main.py Projeto: mcaudy/tubes
@handler.get('^/callback(.*?)$', produces=tubes.TEXT)
def confirm_subscription(request, info):
    if 'hub.challenge' in request.args:
        return request.args['hub.challenge']

    print 'hub.challenge not present in request.args'

@handler.get('^/new-notices/?$', produces=tubes.HTML)
def get_new_notices(request):
    css = h.css('/files/style.css')
    div = h.div(id='timeline')
    html = h.html(h.head(h.title('notices'), css), h.body(div))

    try:
        while True:
            notice = new_notices.get(0, False)
            div.add(notice_to_html(notice))
    except Queue.Empty:
        pass

    return str(html)

REQUESTS = intertubes.generate_requests(handler)
MODEL = intertubes.generate_model([User, Notice])
TEST_PAGE = intertubes.generate_html_example(handler,
        ('/files/json2.js', '/model.js'))

if __name__ == '__main__':
    tubes.run(handler, port=PORT, use_reloader=True, use_debugger=True)
Exemplo n.º 3
0
    return model.manager.tasks_to_dict(tasks)

@handler.get("^/task-by/expired$")
def tasks_expired(req,):
    """return all the tasks where"""
    tasks = model.manager.get_expired()
    return model.manager.tasks_to_dict(tasks)

@handler.get('^/requests.js/?$', produces=tubes.JS)
def requests(req):
    '''return the requests.js file to interact with this API'''
    return tubes.Response(REQUESTS)

@handler.get('^/model.js/?$', produces=tubes.JS)
def get_model(req):
    '''return the model.js file to interact with this API'''
    return MODEL

@handler.get('^/test.html/?$', produces=tubes.HTML)
def test(req):
    '''return a dummy html to play with the API'''
    return TEST_PAGE

REQUESTS = intertubes.generate_requests(handler)
MODEL = intertubes.generate_model([Tag, Task], "Taskr", False)
TEST_PAGE = intertubes.generate_html_example(handler,
        ('/static/js/json2.js', '/model.js'))

if __name__ == '__main__':
    tubes.run(handler, port=PORT, use_reloader=True, use_debugger=True)