-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhello_Theodore.py
118 lines (49 loc) · 1.74 KB
/
hello_Theodore.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
import os
from flask import Flask, url_for, render_template, request
app = Flask(__name__)
@app.route('/')
def render_main():
return render_template('home.html')
@app.route('/ctof')
def render_ctof():
return render_template('ctof.html')
@app.route('/ftoc')
def render_ftoc():
return render_template('ftoc.html')
@app.route('/mtokm')
def render_mtokm():
return render_template('mtokm.html')
@app.route('/ftoc-result')
def render_ftoc_result():
try:
ftemp_result = float(request.args['ftemp'])
ctemp_result = ftoc(ftemp_result)
return render_template('ftoc_result.html', ftemp=ftemp_result, ctemp=ctemp_result)
except ValueError:
return "Sorry: something went wrong."
@app.route('/ctof-result')
def render_ctof_result():
try:
ctemp_result = float(request.args['ctemp'])
ftemp_result = ctof(ctemp_result)
return render_template('ctof_result.html', ctemp=ctemp_result, ftemp=ftemp_result)
except ValueError:
return "Sorry: something went wrong."
@app.route('/mtokm-result')
def render_mtokm_result():
try:
mdist_result = float(request.args['mdist'])
kmdist_result = miles_to_km(mdist_result)
return render_template('mtokm_result.html', kmdist=kmdist_result, mdist=mdist_result)
return render_template('mtokm.html')
except ValueError:
return "Sorry: something went wrong."
def ftoc(ftemp):
return (ftemp - 32.0) * (5.0 / 9.0)
def ctof(ctemp):
return (ctemp *9/5) + 32
def miles_to_km(miles):
return (miles*1.60934)
# You'll probably want a basic function here to convert miles to kilometers too...
if __name__=="__main__":
app.run(host='0.0.0.0')