This project provides an example server for the Sustainable Mobility API project.
In order to run the server, you will need a few system dependencies:
- Python 3
- pipenv
You can install the project with the following command from within the api
directory:
pipenv install
Once pipenv has installed the project, you can launch the virtual environment with this command:
pipenv shell
Once the virtual environment is active and dependencies are installed, you can run the example server by running the following command:
python app.py
Once the server is running, you can access the documentation UI to try it out:
We provide an example_request.json
file in the api
directory. Use the following command to test out the API from the command line:
curl -X POST -H "Content-Type: application/json" -d @example_request.json "http://localhost:8080/estimate-co2"
Use docker-compose to bring the docker container with API and documentation:
docker-compose up -d
You can use serverless framework to deploy estimate-co2 API to the AWS Lambda environment.
To deploy CloudFormation stack with function available publically via HTTPs, issue following commands:
npm i -g serverless
npm install
serverless deploy
pipenv run serverless invoke local -f post -p example_request.json