This repository contains code for get name api endpoints.
-
Install python 3.7.
-
Install pip3
sudo apt install python3-pip
- Install packages:
sudo pip3 install -r requirements.txt
A file .travisyml
exists that contains configuration for the CI pipeline. Once travis ci is configured to use this application, the pipeline will be trigerred automatically.
1.1. Deploy application locally:
python3 app.py
NOTE
In the app.py
file the default port is 5000
because flask server uses it(not manditory). If you want to change the port just change it in the app.py
file and run the comamnd given above.
If you use flask run command it will not use the port specified in the app.py
file. So to change the port run the command given below:
flask run -p <5121>
- List of endpoints:
# endpoint to get the webpage
http://localhost:5000/
# endpoint to get the json response
http://localhost:5000/message?name=Irtiza
1.2. Application is deploy on heroku on this link
# endpoint to get the webpage
https://irtiza-get-name.herokuapp.com/
# endpoint to get the json response, either open in a browser or use cli
https://irtiza-get-name.herokuapp.com/message?name=Irtiza
- Create virtual env:
python3 -m venv venv/
- Activate the virtual environment:
source venv/bin/activate
- Install packages:
pip3 install -r requirements.txt
-
Create a Procfile, it is already created. This file tells heroku to run a commands. The web command tells Heroku to start a web server for the application, using gunicorn. Application is called app.py, therfore app name has been set as
app
. -
Configure heroku repository:
heroku create flask-cicd-using-travis-heroku
- Heroku maintains the repository itself, to check it use the command given below:
cat .git/config
# you can see that a remote orgin named heroku has been added
- Push your code to the repository:
git push heroku master
Once the above command is executed successfully it will output the deployed application url.
- To the the linting:
./pycheck
- To test the code:
# Make sure server is running locally before executing the command below
python3 test_datetime_service.py