This repository has been archived by the owner on Jun 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
59 lines (47 loc) · 2.04 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
import os
from flask import Flask, jsonify, redirect, render_template, request, send_from_directory, url_for
from src import startWithInputOfLatLongString
app = Flask(__name__)
@app.route('/')
def index():
# print('Request for index page received')
# return render_template('index.html')
print('Request for explore page received')
return render_template('explore.html')
@app.route('/explore')
def explore():
print('Request for explore page received')
return render_template('explore.html')
@app.route('/favicon.ico')
def favicon():
return send_from_directory(os.path.join(app.root_path, 'static'),
'favicon.ico', mimetype='image/vnd.microsoft.icon')
# @app.route('/hello', methods=['POST'])
# def hello():
# name = request.form.get('name')
# if name:
# print('Request for hello page received with name=%s' % name)
# return render_template('hello.html', name = name)
# else:
# print('Request for hello page received with no name or blank name -- redirecting')
# return redirect(url_for('index'))
@app.route('/fieldStopIntro', methods=['POST'])
def fieldStopIntro():
data = request.json
if 'latitude' in data and 'longitude' in data:
if (type(data['latitude']) == float and type(data['longitude'] == float)):
latitude = data['latitude']
longitude = data['longitude']
response = {'latitude': latitude, 'longitude': longitude}
# function that calls LLM, returns full json of response
latLongAsString = "latitude = "+str(latitude)+", longitude = "+str(longitude)
response = startWithInputOfLatLongString(latLongAsString)
return jsonify(response)
else:
return jsonify({'error': 'Invalid input, expects floats in value of latitude and longitude keys'})
else:
return jsonify({'error': 'Invalid input, expects an object with keys of latitude and longitude'})
# if __name__ == '__main__':
# app.run(host='0.0.0.0')
if __name__ == '__main__':
app.run()