A skeleton Python web app using Flask.
Fork this project to create a repo under your own GitHub account, so that you can commit and push to it. Then clone the code from your fork onto your machine.
Make sure you have Python 3 installed.
$ cd skeleton-python-app
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install -r requirements.txt
$ python webserver.py
Now try the following request in your browser: [http://localhost:5000/api?q=Who wrote Romeo and Juliet?]
This should call the code in queryprocessor.py
.
The skeleton app comes with a small set of unit tests (see the file queryprocessortest.py
), which you can add to as you add functionality. Run the tests like this:
$ cd skeleton-node-js-app
$ pytest queryprocessortest.py
Log in to https://travis-ci.org using your GitHub account. Click the +
or Add New Respository
on the left, find your new repository and click the slider to enable builds.
-
Manually.
Download the Heroku CLI and use it to log in.
Once you've logged in to Heroku and created an app, this will add a generated Heroku Git remote to your local Git repository.
This adds a Git
remote
to your local repository so that you can rungit push heroku master
to deploy it manually by transferring your code to Heroku's Git repo. You should see this if you run:git remote -v
Another way to add the remote is to run a command like:
heroku git:remote -a robbie-spike-horse-bucket
Test your application is deployed at a URL similar to https://robbie-spike-horse-bucket.herokuapp.com
-
Deploy automatically after a green build
-
Run
heroku auth:token
to generate an Heroku authorisation token. -
You would encrypt this value with the
travis
command but if you don't have the Travis CLI installed, use this site (use something likerchatley/skeleton-java-app
for the repository field) -
Create a
deploy
section to yourtravis.yml
(see the Travis docs) -
Add the encrypted value to the
deply
section of yourtravis.yml
. -
Make a change and push, check the travis log to see if it deploys.
-
NB. You will likely need to add the app
value if your GitHub repo's name doesn't match the Heroku app name.
Your travis.yml
should look something like this.
language: python
python:
- "3.6"
# command to install dependencies
install:
- pip install -r requirements.txt
# command to run tests
script:
- pytest queryprocessortest.py
deploy:
provider: heroku
api_key:
secure: EPYf4T4U9WfJzHi4/CVp4Eom3PXark9x5fbQ23DGw/bjGxpnqMbqv8=
app: robbie-spike-horse-bucket