This server was generated by the swagger-codegen project. By using the OpenAPI-Spec from a remote server, you can easily generate a server stub. This is an example of building a swagger-enabled Flask server.
This example uses the Connexion library on top of Flask.
Python 3.5.2+ Ensure the port you want to run on is defined in your environment as a variable named GEOCODER_PORT. Ensure the host url you want to run on is defined in your environment as a variable named GEOCODER_HOST. Ensure the your Google API key is defined in your environment as a variable named GOOGLE_API_KEY.
To run the server, please execute the following from the root directory:
pip3 install -r requirements.txt
python3 -m swagger_server
and open your browser to here:
http://localhost:8080/geocoder/ui/
Your Swagger definition lives here:
http://localhost:8080/geocoder/swagger.json
To launch the integration tests, run pytest:
pytest
To run the server on a Docker container, please execute the following from the root directory:
# building the image
docker build --build-arg GEOCODER_PORT=$GEOCODER_PORT --build-arg GEOCODER_HOST=$GEOCODER_HOST --build-arg GOOGLE_API_KEY=$GOOGLE_API_KEY -t geocoder_server ./
# starting up a container
docker run -p $GEOCODER_PORT:$GEOCODER_PORT geocoder_server
To generate more example curl commands, go to http://localhost:8080/geocoder/ui/ and click through the interface.
curl -X GET --header 'Accept: application/json' 'http://localhost:8080/geocoder/forwd?location=San%20Francisco'
{
"accuracy": "APPROXIMATE",
"address": "San Francisco, CA, USA",
"bbox": {
"northeast": [
37.812,
-122.3482
],
"southwest": [
37.70339999999999,
-122.527
]
},
"city": "SF",
"confidence": 3,
"country": "US",
"county": "San Francisco County",
"lat": 37.7749295,
"lng": -122.4194155,
"ok": true,
"place": "ChIJIQBpAG2ahYAR_6128GcTUEo",
"quality": "locality",
"state": "CA",
"status": "OK"
}
This API makes use of the Google Geocoding API. For error responses not documented in the Swagger documentation, see the linked Google documentation.