Esempio 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()])
application.add_route("/", common_resources.ResourceHome())

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

application.add_route("/anuncis/create",
                      anunci_resources.ResourceCreateAnunci())
application.add_route("/anuncis/list", anunci_resources.ResourceGetAnuncis())
application.add_route("/anuncis/show/{id}",
                      anunci_resources.ResourceGetAnunci())

application.add_route("/users/register", user_resources.ResourceRegisterUser())
application.add_route("/users/show/{username}",
                      user_resources.ResourceGetUserProfile())
application.add_sink(handle_404, "")
Esempio n. 2
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, "")