The Subbredit Presenter is a full stack application to present Reddit.com subreddits in a useful way.
- General info
- Screenshots
- Technologies
- Link to the website (UI version)
- Setup
- How to run
- How it works
- Features
- Status
This project uses Python flask , JavaScript and HTML in order to display information about the articles of the subbredit asked by the user.
- Server - Python (3.7) flask
- Client - JavaScript, HTML
- install python 3 (or above)
- install pip (sudo apt-get install python3-pip)
- install flask (pip3 install Flask)
- On terminal run: git clone https://github.com/yarink3/subreddit-presenter.git cd subreddit-presenter
- This Project has 2 version, command line version and GUI version.
- To run the command line version ,run: first_version.py
- To run the GUI version ,run python3 app.py go to http://localhost:5000/ and follow the instructions
- A flask application created from 'app.py' , renders the template 'index.html' and creates a server.
- The user fill the form - ask for a specific subreddit and the number of articles (up to 100), sent by post request to the server with the deatails.
- The server converts the json from the reddit website, send it back to the client and the deatails being displayed to the user.
def get_articles(subreddit, num_of_articles):
id = 0
message_lst = []
params = (('limit', str(num_of_articles)),)
while (True):
try:
response = requests.get(f'https://www.reddit.com/r/{subreddit}/.json', headers=headers, params=params)
json_respone = response.json()
datas_children = json_respone['data']['children']
for item in datas_children:
article = [{
"id": id,
"Title": item['data']['title'],
"Author": item['data']['author'],
"Url": item['data']['url'],
"Posted at": get_date(int(item['data']['created_utc'])),
"Score": item['data']['score'],
}]
article = article[0]
message_lst.append(f"Article number {str(article['id'] + 1)}:\n ")
message_lst.append(f"Title: {article['Title']}")
message_lst.append(f"by {article['Author']}/")
message_lst.append(f"Article's link: {article['Url']}\n")
message_lst.append(f"Posted on {article['Posted at']}\n")
message_lst.append(f"Has a score of {article['Score']} \n")
message_lst.append("\n")
id = id + 1
except:
return ["wrong subreddit name, Please try again"]
return message_lst
- Rest API - to communicate between the server and the client.
Project is: finished