This demo explains how to take a Github repository and deploy it to the world!
- On https://github.com/new, create a new repository (personal, not owned by org) called
lect6
- In terminal, clone the repo:
git clone https://github.com/NJIT-CS490-SP21/lect6-demo-heroku.git
cd
into the repository and you should see all the files now.- Then, connect this repo to your personal repo from Step 1:
git remote set-url origin https://www.github.com/[your-username]/lect6
(be sure to change your username) - Run
git push origin main
to push the local repo to remote.
- Follow the instructions here: https://developer.nytimes.com/get-started
pip install python-dotenv
pip install requests
- Create
.env
file in your main directory - Add your NYT key from https://developer.nytimes.com/my-apps with the line:
export NYT_KEY='YOUR_KEY'
- In
app.py
, change Line 13 to a topic you want to get news about!
- Run command in terminal
python app.py
- Preview web page in browser '/'
- Install Heroku CLI:
npm install -g heroku
. This could take a few minutes. In the meantime... - Create a free account on Heroku https://signup.heroku.com/login
- Create a
requirements.txt
file with all your dependencies (Flask
w/ a capital F,requests
,python-dotenv
) - Create a
Procfile
with the command needed to run your app: https://devcenter.heroku.com/articles/getting-started-with-python#define-a-procfile - Add commit all changed files with git
- Log in to Heroku:
heroku login -i
- Create a Heroku app:
heroku create
- Push your code to Heroku:
git push heroku main
- Open your app on the INTERNET (it won't work yet):
heroku open
- Go to https://dashboard.heroku.com/apps and click your App, then go to Settings, and click "Reveal Config Vars"
- Add your secret key from
.env
with the matching variable name (NYT_KEY
) and value (your key, without quotation marks!)