-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
26 lines (21 loc) · 727 Bytes
/
Copy pathapp.py
File metadata and controls
26 lines (21 loc) · 727 Bytes
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
#main.py
from flask import Flask, request, render_template
import estimators
app= Flask(__name__)
@app.route("/") #decorator
def hello():
return render_template("index.html")
@app.route("/estimate", methods=["POST"])
def estimate():
algorithm = request.form['algorithm']
iterations = request.form['iterations']
if algorithm =='mc':
estimate = estimators.estimate_mc(int(iterations))
elif algorithm =='wallis':
estimate = estimators.estimate_wallis(int(iterations))
names = { 'mc':'Monte Carlo estimation',
'wallis' : 'Wallis Product estimation'}
return render_template("estimate.html",
algorithm = names[algorithm],
iters = iterations,
estimate = estimate)