This repository implements a Flask-based website that displays the top and newest questions with an android tag from StackOverflow.
In order to run the project, there are a few dependencies that need to be installed.
- StackAPI - The StackOverflow API
- Flask - The webframework used
- Calendar - Used to get number of days in a month
- Schedule - Used to schedule website updates
On Mac, simply running pip install [name of dependency]
should do the trick.
-
Navigate to the project folder.
-
Execute
export FLASK_APP=flask_website.py
in Terminal or CMD. -
Finally, run the program by executing
python flask_website.py
.
The website, "ANDROIDPHILE", gets its data as a JSON from StackOverflow using StackAPI. The first API call returns a JSON of the top android posts from the last week. The second API call returns a JSON of the most recent android posts.
I found the most convenient way of displaying the question thread was simply to have the post titles link to the actual threads on StackOverflow, not only was this more convenient for me but the JSONs returned by the API did not actually contain question thread information so there was no way for me to recreate a question thread on ANDROIDPHILE.
Since this website is about keeping up to the date with the most-recent and top-rated posts, I added a custom feature which takes the JSON data and plots the reputation of each of the posters. This way, someone on ANDROIDPHILE can make a choice as to which question they want to look at based on the quality of the poster in addition to the quality of the post itself.
The website is scheduled to auto-update every 10 seconds.
top_android_questions.py
is a library that implements the StackOverflow class (more details in the file).
flask_website.py
instantiates the website by creating a Flask instance.
home.html
is where the content of the website is contained.
layout.html
is where the styles and functions used in home.html
are defined.