-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.py
79 lines (68 loc) · 2.55 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
from flask import Flask, request, render_template, jsonify, redirect
from physics.coordinateSystem import SphericalCoordinatesFromPoint
from physics.approximate import convertToMultipleOfPi
import physics.quantities as quantities
import physics.dimensions as dimensions
from search.showSimilarWord import similarQuantity
import time
import os
app = Flask(__name__)
@app.route('/')
@app.route('/home')
def index():
return render_template('home.html')
@app.route('/changeincoordinate')
def changeInCoordinate():
return render_template('changeInCoordinate.html')
@app.route('/cartesianchange')
def cartesianChange():
return render_template('cartesianChange.html')
@app.route('/dimension')
def dimension():
data = quantities.quantity
return render_template('dimension.html', suggestion = data, toggle = 1)
@app.route('/dimension/table', methods=['GET', 'POST'])
def dimensionTable():
if request.method == "POST":
headings = ("Quantity", "Dimensions")
data = request.form.get('quantity')
data = data.lower()
showAll = request.form.get("showAll")
if showAll == "yes" and data == "":
row = []
for data in quantities.quantity:
row.append([data, dimensions.dimensions[data]])
return render_template('table.html', headings=headings, row=row, suggestion=quantities.quantity, toggle = 0)
elif showAll == "no" and data=="":
return redirect('/dimension')
else:
try:
data = data.strip(" ")
row = [[data, dimensions.dimensions[data]]]
return render_template('table.html', headings=headings, row=row, suggestion=quantities.quantity,toggle = 1)
except:
quantity = similarQuantity(data)
return render_template('didYouMean.html', quantity=quantity, suggestion=quantities.quantity, toggle=1)
return redirect('/dimension')
@app.route('/sphericalchanged', methods=['GET', 'POST'])
def sphericalChanged():
if request.method == "POST":
# getting input with name = fname in HTML form
x = request.form.get("x")
# getting input with name = lname in HTML form
y = request.form.get("y")
z = request.form.get("z")
to = request.form.get("to")
point = SphericalCoordinatesFromPoint((float(x), float(y), float(z)))
r = point.getR()
theta = point.getTheta()
phi = point.getPhi()
#theta = convertToMultipleOfPi(point.getTheta())
#phi = convertToMultipleOfPi(point.getPhi())
return render_template("sphericalChanged.html",x=x, y=y, z=z, r=r, theta=theta, phi=phi, to=to)
return render_template("cartesianChange.html")
@app.route('/aboutUs')
def aboutUs():
return render_template('aboutUs.html')
if __name__ == "__main__":
app.run(debug=True)