-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from beveradb/add-basic-web-ui
Created responsive web UI to replace primitive CLI usage, added drive time and variety of robustness improvements.
- Loading branch information
Showing
24 changed files
with
771 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
.DS_Store | ||
mapbox-polygon-temp.html | ||
__pycache__ | ||
*.pyc | ||
*.swp | ||
.idea |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: python run_server.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ celery | |
fiona | ||
descartes | ||
pyproj | ||
geopy | ||
geopy | ||
flask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env python3 | ||
import os | ||
|
||
from flask import Flask, render_template, jsonify | ||
from shapely.geometry import mapping | ||
|
||
from src import target_area | ||
|
||
app = Flask(__name__) | ||
|
||
|
||
@app.route('/') | ||
def index(): | ||
# This script requires you have environment variables set with your personal API keys: | ||
# MAPBOX_ACCESS_TOKEN from https://docs.mapbox.com/help/how-mapbox-works/access-tokens/ | ||
# TRAVELTIME_APP_ID from https://docs.traveltimeplatform.com/overview/introduction | ||
# TRAVELTIME_API_KEY from https://docs.traveltimeplatform.com/overview/introduction | ||
|
||
return render_template( | ||
'index.html', | ||
MAPBOX_ACCESS_TOKEN=os.environ['MAPBOX_ACCESS_TOKEN'] | ||
) | ||
|
||
|
||
@app.route('/target_area/<string:target>/<int:walking>/<int:pubtrans>/<int:driving>/<int:deprivation>') | ||
def target_area_json( | ||
target: str, | ||
walking: int, | ||
pubtrans: int, | ||
driving: int, | ||
deprivation: int | ||
): | ||
polygon_results = target_area.get_target_area_polygons( | ||
target_location_address=target, | ||
min_deprivation_score=deprivation, | ||
max_walking_time_mins=walking, | ||
max_public_transport_travel_time_mins=pubtrans, | ||
max_driving_time_mins=driving | ||
) | ||
for key, value in polygon_results.items(): | ||
if 'polygon' in value: | ||
polygon_results[key]['polygon'] = mapping(value['polygon']) | ||
|
||
return jsonify(polygon_results) | ||
|
||
|
||
if __name__ == '__main__': | ||
port = os.environ['PORT'] if 'PORT' in os.environ else 9876 | ||
app.run(debug=True, host='0.0.0.0', port=port, use_evalex=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python-3.7.4 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.