Skip to content

raymonst/flask-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IO Lab 20: Flask and Redis on Heroku

Assignment Description

For this lab you will create a basic site statistics app using Flask and Redis, and deploy it to Heroku.

Step 1: Heroku Setup

Follow the instructions in the Getting Started Guide to install Heroku/the Heroku Toolbelt on your machine. After you have entered your Heroku credentials at the command line, continue to step 2.

Step 2: Download Sample App

Clone this repository to your computer. Navigate to the project directory and delete the existing .git folder.

Step 3: Create Heroku App

  1. From the project directory, type git init to initialize a fresh git repo, then add and commit all of the files.
  2. Type heroku create to create a new heroku app. Heroku will respond with the URL for your new site, something like "Creating wandering-pines-3938... done, stack is cedar, http://wandering-pines-3938.herokuapp.com"
  3. Give the app a better name than the autogenerated one with heroku rename "newname". For example, heroku rename "iloveiolab" will change the name of the app to iloveiolab and the address will now be http://iloveiolab.herokuapp.com.
  4. Install the redis add-on for your site with heroku addons:add redistogo

Step 4: Deploy!

Deploy the test app to Heroku with git push heroku master. Go to the app's URL in the browser and verify you see a page appear. Refresh the page and watch the counter go up.

Step 5: Modify the App

Right now the app only keeps track of the number of hits. Modify the code so that it also keeps a log of what operating system visitors are using (hint: take a look at Flask's request.user_agent output, and the python module httpagentparser). Print the result to the index.html page. For example:
Windows: 10
Mac: 1

If you have time, log the user's browser as well, and make a visualization of the data (pie chart? bar chart?)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published