From e66e74e3121931a8b8ede6ffb5222523c85e623d Mon Sep 17 00:00:00 2001 From: Priyansh Date: Wed, 17 Nov 2021 15:04:59 -0500 Subject: Re-writing for deploying to Heroku --- Procfile | 1 + README.md | 2 +- __pycache__/app.cpython-38.pyc | Bin 0 -> 231 bytes app.py | 44 ------------------------------------ app/__pycache__/main.cpython-38.pyc | Bin 0 -> 1437 bytes app/main.py | 32 ++++++++++++++++++++++++++ wsgi.py | 4 ++++ 7 files changed, 38 insertions(+), 45 deletions(-) create mode 100644 Procfile create mode 100644 __pycache__/app.cpython-38.pyc delete mode 100644 app.py create mode 100644 app/__pycache__/main.cpython-38.pyc create mode 100644 app/main.py create mode 100644 wsgi.py diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..fc272ab --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: gunicorn wsgi:app \ No newline at end of file diff --git a/README.md b/README.md index 98106e2..7624c62 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ pip install -r requirements.txt Run the Project: ``` -python app.py +python wsgi.py ``` ## Project Structure diff --git a/__pycache__/app.cpython-38.pyc b/__pycache__/app.cpython-38.pyc new file mode 100644 index 0000000..0899514 Binary files /dev/null and b/__pycache__/app.cpython-38.pyc differ diff --git a/app.py b/app.py deleted file mode 100644 index 5c97d70..0000000 --- a/app.py +++ /dev/null @@ -1,44 +0,0 @@ -from flask import Flask, render_template -from flask import Markup -import sqlite3 as sql -import pandas as pd - -app = Flask(__name__) - - -def execute_sql_statement(sql_statement, conn): - cur = conn.cursor() - cur.execute(sql_statement) - - rows = cur.fetchall() - - return rows - -def get_list_of_dict(keys, list_of_tuples): - list_of_dict = [dict(zip(keys, values)) for values in list_of_tuples] - return list_of_dict - -def get_cities_list(): - conn = sql.connect("database.db") - sql_statement = 'SELECT DISTINCT(City_Name) as City_Name, Lat, Long FROM City_table join Loc_Table on City_Table.City_Id = Loc_table.City_Id' - df=pd.read_sql_query(sql_statement, conn).to_records(index=False) - return df - -@app.route("/") -@app.route("/index") -def index(): - - cities_list = get_cities_list() - keys = ("city", "latitude", "longitude") - cities_list = get_list_of_dict(keys, cities_list) - # start_coords = (42.9974521, -78.7907883) - # folium_map = folium.Map(location=start_coords, zoom_start=14) - # _ = folium_map._repr_html_() - # map_div = Markup(folium_map.get_root().html.render()) - # hdr_txt = Markup(folium_map.get_root().header.render()) - # script_txt = Markup(folium_map.get_root().script.render()) - return render_template("index.html", cities_list=cities_list) - - -if __name__ == '__main__': - app.run(debug=True) diff --git a/app/__pycache__/main.cpython-38.pyc b/app/__pycache__/main.cpython-38.pyc new file mode 100644 index 0000000..478e41c Binary files /dev/null and b/app/__pycache__/main.cpython-38.pyc differ diff --git a/app/main.py b/app/main.py new file mode 100644 index 0000000..c2308f9 --- /dev/null +++ b/app/main.py @@ -0,0 +1,32 @@ +from flask import Flask, render_template +from flask import Markup +import sqlite3 as sql +import pandas as pd + +app = Flask(__name__) + + +def execute_sql_statement(sql_statement, conn): + cur = conn.cursor() + cur.execute(sql_statement) + rows = cur.fetchall() + return rows + +def get_list_of_dict(keys, list_of_tuples): + list_of_dict = [dict(zip(keys, values)) for values in list_of_tuples] + return list_of_dict + +def get_cities_list(): + conn = sql.connect("database.db") + sql_statement = 'SELECT DISTINCT(City_Name) as City_Name, Lat, Long FROM City_table join Loc_Table on City_Table.City_Id = Loc_table.City_Id' + df=pd.read_sql_query(sql_statement, conn).to_records(index=False) + return df + +@app.route("/") +@app.route("/index") +def index(): + + cities_list = get_cities_list() + keys = ("city", "latitude", "longitude") + cities_list = get_list_of_dict(keys, cities_list) + return render_template("index.html", cities_list=cities_list) \ No newline at end of file diff --git a/wsgi.py b/wsgi.py new file mode 100644 index 0000000..2e6a19f --- /dev/null +++ b/wsgi.py @@ -0,0 +1,4 @@ +from app.main import app + +if __name__ == '__main__': + app.run(debug=True) -- cgit v1.2.3