Ejemplo n.º 1
0
# DEFAULT 404
# noinspection PyUnusedLocal
def handle_404(req, resp):
    resp.media = messages.resource_not_found
    resp.status = falcon.HTTP_404


# FALCON
app = application = falcon.API(
    middleware=[
        middlewares.DBSessionManager(),
        middlewares.Falconi18n(),
        MultipartMiddleware()
    ]
)
application.add_route("/", common_resources.ResourceHome())

application.add_route("/account/profile", account_resources.ResourceAccountUserProfile())
application.add_route("/account/profile/update_profile_image", account_resources.ResourceAccountUpdateProfileImage())
application.add_route("/account/create_token", account_resources.ResourceCreateUserToken())
application.add_route("/account/delete_token", account_resources.ResourceDeleteUserToken())

application.add_route("/users/register", user_resources.ResourceRegisterUser())
application.add_route("/users/show/{username}", user_resources.ResourceGetUserProfile())

application.add_route("/events", event_resources.ResourceGetEvents())
application.add_route("/events/show/{id:int}", event_resources.ResourceGetEvent())
application.add_route("/events/mostra/{name}", event_resources.ResourceGetName())

application.add_sink(handle_404, "")
Ejemplo n.º 2
0
    resp.media = messages.resource_not_found
    resp.status = falcon.HTTP_404


# FALCON
app = application = falcon.API(middleware=[
    middlewares.DBSessionManager(),
    middlewares.Falconi18n(),
    MultipartMiddleware()
])
application.add_route("/", common_resources.ResourceHome())

application.add_route("/account/profile",
                      account_resources.ResourceAccountUserProfile())
application.add_route("/account/profile/update_profile_image",
                      account_resources.ResourceAccountUpdateProfileImage())
application.add_route("/account/create_token",
                      account_resources.ResourceCreateUserToken())
application.add_route("/account/delete_token",
                      account_resources.ResourceDeleteUserToken())

application.add_route("/users/register", user_resources.ResourceRegisterUser())
application.add_route("/users/show/{username}",
                      user_resources.ResourceGetUserProfile())
application.add_route("/users/list", user_resources.ResourceGetUsers())

application.add_route("/trivial/question/list",
                      trivial_events.ResourceGetQuestions())
application.add_route("/trivial/question",
                      trivial_events.ResourceGetRandomQuestion())
application.add_route("/trivial/question/add",