forked from hackathon-in-a-box/example-hackathon-submission
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
146 lines (100 loc) · 4.35 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import os
from flask import Flask, render_template, request, redirect, url_for
from flask.ext.sqlalchemy import SQLAlchemy
import requests
sqlite_file = "sqlite:////tmp/flask_app.db"
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get('DATABASE_URL',
sqlite_file)
db = SQLAlchemy(app)
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(100))
email = db.Column(db.String(100))
def __init__(self, name, email):
self.name = name
self.email = email
@app.route('/')
def index():
return render_template('index.html', users=User.query.all())
@app.route('/user', methods=['POST'])
def user():
if request.method == 'POST':
u = User(request.form['name'], request.form['email'])
db.session.add(u)
db.session.commit()
return redirect(url_for('index'))
@app.route('/maptest', methods=['GET'])
def maptest():
payload = {'key': '8e4402d8-6f8d-49fe-8e7c-d3d38098b4ef', 'lat': '47.606115', 'lon': '-122.335834', 'radius': '800'}
if 'stop_id' in request.args:
stop_id = str(request.args.get('stop_id', ''))
r = requests.get("http://api.pugetsound.onebusaway.org/api/where/stop/" + stop_id + ".json", params={'key': '8e4402d8-6f8d-49fe-8e7c-d3d38098b4ef'})
response = r.json()
payload['lat'] = float(response['data']['entry']['lat'])
payload['lon'] = float(response['data']['entry']['lon'])
elif 'lat' in request.args:
lat = request.args.get('lat', '')
lon = request.args.get('lon', '')
payload['lat'] = float(lat)
payload['lon'] = float(lon)
#r = requests.get("http://api.pugetsound.onebusaway.org/api/where/current-time.xml", params=payload)
#r = requests.get("http://api.pugetsound.onebusaway.org/api/where/stops-for-location.xml", params=payload)
r = requests.get("http://api.pugetsound.onebusaway.org/api/where/stops-for-location.json", params=payload)
response = r.json()
stop_list = []
for stop in response['data']['list']:
stop_list.append({'lat': stop['lat'],
'lon': stop['lon'],
'name': stop['name']})
return render_template('maptest.html', responsedata=stop_list, lat=payload['lat'], lon=payload['lon'], stop_id=request.args.get('stop_id', ''))
@app.route('/maptest-longpress')
def maptestlong(location=None):
payload = {'key': '8e4402d8-6f8d-49fe-8e7c-d3d38098b4ef', 'lat': '47.606115', 'lon': '-122.335834', 'radius': '800'}
#r = requests.get("http://api.pugetsound.onebusaway.org/api/where/current-time.xml", params=payload)
#r = requests.get("http://api.pugetsound.onebusaway.org/api/where/stops-for-location.xml", params=payload)
r = requests.get("http://api.pugetsound.onebusaway.org/api/where/stops-for-location.json", params=payload)
response = r.json()
stop_list = []
for stop in response['data']['list']:
stop_list.append({'lat': stop['lat'],
'lon': stop['lon'],
'name': stop['name']})
return render_template('maptest-longpress.html', responsedata=stop_list, lat='47.606115', lon='-122.335834')
@app.route('/curbmap')
def curbmap():
return render_template('curbmap.html')
@app.route('/elevationmap')
def elevationmap():
return render_template('elevationmap.html')
@app.route('/curbmap_lines')
def curbmap_lines():
return render_template('curb_lines_stringent.html')
@app.route('/report')
def report():
return render_template('report.html')
@app.route('/report-construction')
def construction():
return render_template('report-construction.html')
@app.route('/report-incline')
def incline():
return render_template('report-incline.html')
@app.route('/report-elevator')
def elevator():
return render_template('report-elevator.html')
@app.route('/report-ramp')
def ramp():
return render_template('report-ramp.html')
@app.route('/report-stairs')
def stairs():
return render_template('report-stairs.html')
@app.route('/report-other')
def other():
return render_template('report-other.html')
@app.route('/report-submitted')
def submit():
return render_template('report-submitted.html')
if __name__ == '__main__':
db.create_all()
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)