-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathapp.py
73 lines (53 loc) · 1.8 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import pandas as pd
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
from sqlalchemy import create_engine, func
from flask import Flask, jsonify, render_template, url_for
#################################################
# Database Setup
#################################################
engine = create_engine("sqlite:///keyword_clustering.sqlite")
conn = engine.connect()
# reflect an existing database into a new model
Base = automap_base()
# reflect the tables
Base.prepare(engine, reflect=True)
#################################################
# Flask Setup
#################################################
app = Flask(__name__)
#################################################
# Flask Routes
#################################################
########## Home Page ##########
@app.route("/")
def index():
return render_template("index.html")
@app.route("/google-data-studio-dashboard")
def gds_studio():
return render_template("gds_dashboard.html")
@app.route("/tableau-dashboard")
def tableau():
return render_template("tableau_dashboard.html")
@app.route("/about")
def about():
return render_template("about.html")
@app.route("/contact")
def contact():
return render_template("contact.html")
@app.route("/directories")
def welcome():
"""List all available api routes."""
return (
f"Welcome to SEO Keyword Clusters<br/>"
f"Here is the URL for JSON Data:<br/>"
f"/keyword_clustering_data<br/>"
)
########## Keyword Clustering ##########
# Query our keyword clustering data
keyword_clustering_data = pd.read_sql("SELECT * FROM keyword_clustering", conn)
@app.route("/keyword_clustering_data")
def keyword_clustering():
return jsonify(keyword_clustering_data.to_dict())
if __name__ == '__main__':
app.run(debug=True)