-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpiServer.py
More file actions
60 lines (49 loc) · 1.77 KB
/
piServer.py
File metadata and controls
60 lines (49 loc) · 1.77 KB
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
from flask import Flask, send_from_directory, request
app = Flask(__name__)
def replace_line(file_name, line_num, text):
lines = open(file_name, 'r').readlines()
lines[line_num] = str(text) + '\n'
with open('base.txt', 'w') as file:
file.writelines(lines)
file.close()
@app.route('/userInput', methods=['POST'])
def userInput():
return send_from_directory("", "index.html")
@app.route('/destination', methods=['POST'])
def destination():
destinationAddress = request.args.get('address')
replace_line('base.txt',6,destinationAddress)
return send_from_directory("", "index.html")
@app.route('/origin', methods=['POST'])
def origin():
originAddress=request.args.get('address')
replace_line('base.txt',0,originAddress)
return send_from_directory("", "index.html")
@app.route('/timeToArrive', methods=['POST'])
def arrive():
ttaHours = request.args.get('hour')
ttaMin = request.args.get('min')
replace_line('base.txt', 12, ttaHours)
replace_line('base.txt', 13, ttaMin)
return send_from_directory("", "index.html")
@app.route('/prep', methods=['POST'])
def prep():
prepTime = request.args.get('time')
replace_line('base.txt', 5, prepTime)
return send_from_directory("", "index.html")
@app.route('/dataInputFromScript', methods=['POST'])
def dataInputFromScript():
for key in request.args:
with open('base.txt','w') as file:
file.writeline
return 'this is working'
@app.route('/')
@app.route('/<path:filepath>')
def index(filepath='index.html'):
return 'send_from_directory('', filepath)'
# @app.route('/')
# @app.route('/<path:filepath>')
# def index(filepath='index.html'):
# return send_from_directory('views', filepath)
if __name__ == '__main__':
app.run(host='0.0.0.0', port="8000")