-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
32 lines (27 loc) · 864 Bytes
/
app.py
File metadata and controls
32 lines (27 loc) · 864 Bytes
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
from flask import Flask, render_template, redirect
from flask_pymongo import PyMongo
import scrape_mars
# from login_db import myKeys
def myKeys():
return {
"userName": "jmo5896",
"password": "Spansyekoms22"
}
keys = myKeys()
app = Flask(__name__)
app.config["MONGO_URI"] = f"mongodb://{keys['userName']}:{keys['password']}@ds011268.mlab.com:11268/heroku_p589mnvp"
# app.config["MONGO_URI"] = "mongodb://localhost:27017/mars_app"
mongo = PyMongo(app)
@app.route('/')
def home():
mars_data = mongo.db.mars_data.find_one()
# print(mars_data)
return render_template('index.html', mars_data = mars_data)
@app.route('/scrape')
def scrape():
mars_data = scrape_mars.scrape_mars()
mongo.db.mars_data.update({},mars_data, upsert=True)
# print(mars_data)
return redirect('/')
if __name__ == "__main__":
app.run()