Esempio n. 1
0
                "api_endpoint": '/v1/race/state?code={}'.format(state_code.upper()),
            },
            "country": {
                "name": "United States of America",
                "code": "US",
                "api_endpoint": '/v1/race/country?code=US',
            }
        },
        "notes": notes
    })
    http_server.print_headers()
    http_server.print_json(output)


api_manager.set_method_callback(
    ApiManager.HTTP_METHOD_GET,
    handle_get
)


api_manager.require_auth()


try:
    api_manager.run()
except ApiParamNoCityProvidedError:
    http_server.set_status(400)
    json_response = {"error": "A city parameter is required"}
    http_server.print_headers()
    http_server.print_json(json_response)
except ApiParamInvalidCityError:
    http_server.set_status(400)
            raise ApiParamMissingParameterError

    name = post_params["name"]

    pdf_data = PdfData.fetch_by_name_and_account_id(name, account.id)

    if pdf_data is not None:
        raise ApiParamInvalidPdf

    pdf_data.delete()
    http_server.set_status(202)
    http_server.print_json(output)


api_manager.set_method_callback(
    ApiManager.HTTP_METHOD_GET,
    handle_get
)


api_manager.set_method_callback(
    ApiManager.HTTP_METHOD_POST,
    handle_post
)


api_manager.set_method_callback(
    ApiManager.HTTP_METHOD_PUT,
    handle_put
)