-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
54 lines (37 loc) · 1.26 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from flask import Flask, redirect, url_for, render_template, request, session, flash
import requests
import json
import pprint
import os
import read_mongo
import mongo_functions.delete_mongo
# from pymongo import MongoClient
# from dotenv import load_dotenv, find_dotenv
# load_dotenv(find_dotenv())
# connection_string = os.environ.get("MONGODB_URI")
# client = MongoClient(connection_string)
# dbs = client.list_database_names()
# guardiandb = client['the-guardian']
# collections = guardiandb.list_collection_names()
# opinions_collection = guardiandb['opinions']
# printer = pprint.PrettyPrinter()
app = Flask(__name__)
@app.route("/")
def home():
articles = read_mongo.find_all_articles()
count = read_mongo.count_articles()
return render_template('index.html', articles=articles, )
@app.route("/articles")
def get_articles():
data = read_mongo.find_all_articles()
count = read_mongo.count_articles()
articles = []
for article in data:
article['date'] = article['date'].date()
articles.append(article)
return render_template('articles.html', articles=articles, count=count)
@app.route("/vocabulary")
def vocabulary():
return render_template('vocabulary.html')
if __name__ == "__main__":
app.run(debug=True)