-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappchallenge.py
46 lines (35 loc) · 1.05 KB
/
appchallenge.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
from flask import Flask, render_template
from flask_pymongo import PyMongo
import scrapingchallenge
app = Flask(__name__)
# Use flask_pymongo to set up mongo connection
app.config["MONGO_URI"] = "mongodb://localhost:27017/mars_app"
mongo = PyMongo(app)
@app.route("/")
def index():
mars = mongo.db.mars.find_one()
return render_template("index.html", mars=mars)
@app.route("/scrape")
def scrape():
mars = mongo.db.mars
mars_data = scrapingchallenge.scrape_all()
mars.update({}, mars_data, upsert=True)
return "Scraping Successful!"
@app.route("/cerb")
def cerb():
mars = mongo.db.mars.find_one()
return render_template("cerb.html", mars=mars)
@app.route("/schi")
def schi():
mars = mongo.db.mars.find_one()
return render_template("schi.html", mars=mars)
@app.route("/syrt")
def syrt():
mars = mongo.db.mars.find_one()
return render_template("syrt.html", mars=mars)
@app.route("/vall")
def vall():
mars = mongo.db.mars.find_one()
return render_template("vall.html", mars=mars)
if __name__ == "__main__":
app.run()