def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): arg_names = inspect.getargspec(compute).args kwargs = {name: getattr(form, name).data for name in arg_names if hasattr(form, name)} # Run eval on the text # Note that form.name.label is <label for="A">(list)</label> for name in kwargs: if hasattr(form, name) and \ hasattr(getattr(form, name), 'label'): label = str(getattr(form, name).label) for tp in ('(list)', '(tuple)', '(nd.array)'): if tp in label: kwargs[name] = eval(kwargs[name]) result = compute(**kwargs) else: result = None # Concatenate view_forms.html and view_results.html result_render = None if result: result_render = render_template('view_results.html', result=result) return render_template('view_forms.html', form=form, result=result_render)
def index(): form = InputForm(request.form) if form.validate(): result = compute(form.Fsr.data, form.freq.data) else: result = None return render_template('view.html',form=form, result=result)
def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): result = phasePlot(form.XPrime.data, form.YPrime.data) else: result = None return render_template('new_view.html', form=form,result=result)
def index(): form = InputForm(request.form) #form represents an instance of the InputForm if form.validate(): result = compute(form.A.data, form.B.data) #Result holds the output image else: result = None return render_template('view.html', form=form, result=result)
def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): result = compute(form.Formula.data, form.Domain.data, form.Erase.data) else: result = None return render_template('view.html', form=form, result=result)
def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): r = form.r.data s = compute(r) else: s = None return render_template("view.html", form=form, s=s)
def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): result = compute(form.A.data, form.b.data, form.w.data, form.T.data) else: result = None return render_template('view_plain.html', form=form, result=result)
def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): for field in form: exec('{} = {}'.format(field.name, field.data)) result = timeline() else: result = None return render_template(template_name + '.html', result=result)
def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): for field in form: # Make local variable (name field.name) exec('%s = %s' % (field.name, field.data)) result = compute(A, b, w, T) else: result = None return render_template('view.html', form=form, result=result)
def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): result = compute(form.A.data, form.B.data, form.C.data, form.D.data, form.E.data, form.F.data) else: result = None #return render_template('view_errcheck.html', form=form, result=result) return render_template('view_ttl.html', form=form, result=result)
def index(): form = InputForm(request.form) if request.method == "POST" and form.validate(): arg_names = inspect.getargspec(compute).args kwargs = {name: getattr(form, name).data for name in arg_names if hasattr(form, name)} result = compute(**kwargs) else: result = None if result: # result must be transformed to HTML and inserted as a # string in the generic view.html file result = render_template("view_results.html", result=result) return render_template("view.html", form=form, result=result)
def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): for field in form: exec('%s = %s' % (field.name, field.data)) variable = dict(CHOICES).get(form.variable.data) result = plot(form.lon_w.data, form.lon_e.data, form.lat_s.data, form.lat_n.data, variable, form.point_check.data, form.title.data, form.color_bar.data) else: result = None return render_template(template, form=form, result=result)
def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): result = compute(form.A.data, form.b.data, form.w.data, form.T.data) else: result = None print form, dir(form) #print form.keys() for f in form: print f.id print f.name print f.label return render_template(template_name + '.html', form=form, result=result)
def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): result = compute(formula=form.Formula.data, independent_variable=form.Variable.data, N=form.N.data, xmin=form.xmin.data, xmax=form.xmax.data, ymin=form.ymin.data, ymax=form.ymax.data, legend_loc=form.legend_loc.data, x0=form.x0.data, erase=form.Erase.data) else: result = None print request.method, [field.errors for field in form] return render_template('view.html', form=form, result=result)
def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): arg_names = inspect.getargspec(compute).args kwargs = {name: getattr(form, name).data for name in arg_names if hasattr(form, name)} result = compute(**kwargs) else: result = None # Concatenate view_forms.html and view_results.html forms_html = os.path.join('templates', 'view_forms.html') results_html = os.path.join('templates', 'view_results.html') view_html = os.path.join('templates', 'view.html') f_forms = open(forms_html, 'r') f_res = open(results_html, 'r') f_view = open(view_html, 'w') f_view.write(f_forms.read() + f_res.read()) f_forms.close(); f_res.close(); f_view.close() return render_template(os.path.basename(view_html), form=form, result=result)
def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): diode_spice = dict(NBVL=float(form.NBVL.data), NBV=float(form.NBV.data), BV=float(form.BV.data), IBVL=float(form.IBVL.data), IBV=float(form.IBV.data), Isr=float(form.Isr.data), Vj=float(form.Vj.data), M=float(form.M.data), NR=float(form.NR.data), IKF=float(form.IKF.data), N=float(form.N.data), Is=float(form.Is.data)) result = compute(fwd, rev, diode_spice) else: result = None return render_template('view.html', form=form, result=result)
def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): result_t, result_u = compute(form.A.data, form.b.data, form.w.data, form.T.data) #result_t = result_t_f #result_u = result_u_f #result_t = ["%.2f" % number for number in result_t_f] #result_u = ["%.2f" % number for number in result_u_f] n = len(result_t) #result = result_t_f+result_u_f else: n = 0 result_t = None result_u = None return render_template('view.html', form=form, result_t=result_t, result_u=result_u, n=n)
def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): if form.dims.data < 3: raise ValueError("Dimensions should be greater than 2 for a three card SET game") if form.dim_size.data < 3: raise ValueError("Dimension size should be greater than 2 for a three card SET game") s = form.dims.data * [range(form.dim_size.data)] possible_cards = len(list(itertools.product(*s))) if form.n_cards.data > possible_cards: raise ValueError("Number of cards on the deck cannot be greater than %s" %possible_cards) game_set = Sets(form.dims.data, form.dim_size.data, form.n_cards.data) if form.dim_size.data == 3: result = game_set.get_sets() else: result = game_set.getsets_brute() else: result = None return render_template('view.html', form=form, result=result)
def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): result = RFPredict(form.Pregnancies.data, form.Glucose.data, form.BloodPressure.data, form.SkinThickness.data, form.Insulin.data, form.BMI.data, form.DiabetesPedigreeFunction.data, form.Age.data) else: result = None print(form, dir(form)) #print form.keys() #for f in form: # print (f.id) # print (f.name) # print (f.label) if (result == 1): result = "you risk have diabetes :(" if (result == 0): result = "you don't risk have diabetes)" return render_template(template_name + '.html', form=form, result1=result)
def index(): form = InputForm(request.form) # sample_form = SampleForm(request.form) if request.method == 'POST' and form.validate(): o_reso = init_reso(form.e_min.data, form.e_max.data, form.e_step.data) o_reso.add_layer(form.formula.data, form.thickness.data, form.density.data) # if init_form.validate() and sample_form.validate(): # o_reso = init_reso(init_form.e_min.data, # init_form.e_max.data, # init_form.e_step) # result = add_layer(o_reso, # sample_form.formula.data, # sample_form.thickness.data, # sample_form.density.data) result = o_reso.stack plot = o_reso.plot() else: result = None plot = None return render_template('view.html', form=form, result=result, plot=plot)
def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): clue = form.clue.data puzzle_type = form.puzzle_type.data mypuzzlesheet = puzzlesheet.puzzlesheet("tmp/tim_puzzle", "Algebra 101 worksheet 1", clue, savetex=True) mypuzzlesheet.add_section( puzzle_type, 6, "Linear equations", "Use the numerator of the resulting improper fraction to lookup the letter above", rhs=0) mypuzzlesheet.write() return redirect('/return-files/') else: clue = None return render_template("view.html", form=form, clue='defaulto')
def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): result = compute(form.k.data, form.l.data, form.t.data) result = json.loads(result) else: # result = None # {'answer':w[-1],'curve':plotfile} result = {'data': None, 'image': None} print('flask_app_display') print(result) # print (form, dir(form)) #print form.keys() # for f in form: # print (f.id) # print (f.name) # print (f.label) return render_template(template_name + '.html', form=form, image=result['image'], data=result['data'])
def computeResult(): form = InputForm(request.form) numTerms = 0 approximation = 0 if request.method == 'POST' and form.validate(): result = compute(form.decimalPlaces.data, form.speed.data) obj = PiCalc(int(form.decimalPlaces.data)) numTerms = 0 approximation = 0 if (form.speed.data == "Fast"): numTerms = obj.getNumberTermsMachinApprox() print(numTerms) approximation = obj.fast_pi_approximation() print(approximation) else: numTerms = obj.getNumberTermsSlowApprox() print(numTerms) approximation = obj.calculation_slow_approx() print(approximation) else: result = None return render_template("PiCalc.html", form=form, result=result, numTerms=numTerms, approximation=approximation)
def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): result_coherence = calc_coherence(unpack_data(form.text_input)) result_determiners = calc_determiners(unpack_data(form.text_input)) result_phrase_length = calc_phrase_len(unpack_data(form.text_input)) result_delusion_dict = calc_delusions(unpack_data(form.text_input)) result_a1 = result_delusion_dict['time'] result_a2 = result_delusion_dict['self'] result_a3 = result_delusion_dict['surveillance'] result_a4 = result_delusion_dict['unfair'] result_a5 = result_delusion_dict['mind_control'] result_a6 = result_delusion_dict['alien'] result_ml = calc_ml(result_coherence, result_determiners, result_phrase_length, result_a1, result_a2, result_a3, result_a4, result_a5, result_a6) chartID = 'Analytics' chart = {"renderTo": chartID, "type": "bar", "height": 500} series = [ {"name": 'Aim to raise', "data": [ 10**14*min(result_coherence), result_determiners, result_phrase_length, ]}] title = {"text": chartID} xAxis = {"categories": ['Semantic Coherency', 'Determiner Frequency', 'Normalized Max Phrase Length']} yAxis = {"title": {"text": ''}} return render_template('results.html', chartID=chartID, chart=chart, series=series, title=title, xAxis=xAxis, yAxis=yAxis, form=form, result_ml=result_ml) else: return render_template('view.html', form=form)
def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): par.Omega_M = form.Omega_M.data par.Omega_L = form.Omega_L.data par.Hubble = form.Hubble.data reload(Cosmo) m = form.Mvir.data z = form.Redshift.data rvir, vvir, tvir, result = compute(m, z) #rvir = m else: rvir = None vvir = None tvir = None result = None return render_template("view1.html", form=form, rvir=rvir, vvir=vvir, tvir=tvir, result=result)
def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): bedrooms = float(form.bedrooms.data) sqft_living = float(form.sqft_living.data) waterfront = float(form.waterfront.data) view = float(form.view.data) grade = float(form.grade.data) yob = float(form.yob.data) zipcode = form.zipcode.data result, df = compute(bedrooms, sqft_living, waterfront, view, grade, yob, zipcode) return render_template(template_name, form=form, df=df, result='$' + str(int(result))) else: result = None df = None return render_template(template_name, form=form, df=df, result=result)
def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): arg_names = inspect.getargspec(compute).args kwargs = {name: getattr(form, name).data for name in arg_names if hasattr(form, name)} # Run eval on the text # Note that form.name.label is <label for="A">(list)</label> for name in kwargs: if hasattr(form, name) and \ hasattr(getattr(form, name), 'label'): label = str(getattr(form, name).label) for tp in ('(list)', '(tuple)', '(nd.array)'): if tp in label: kwargs[name] = eval(kwargs[name]) result = compute(**kwargs) else: result = None if result: # result must be transformed to HTML and inserted as a # string in the generic view.html file result = render_template('view_results.html', result=result) return render_template('view.html', form=form, result=result)
def index(): form = InputForm(request.form) if request.method == 'POST' and form.validate(): result1, result2 = predict( form.x.data, form.open.data, form.high.data, form.low.data, form.last.data, ) else: result = None print(form, dir(form)) #print form.keys() for f in form: print(f.id) print(f.name) print(f.label) return render_template(template_name + '.html', form=form, result1=result1, result2=result2)
def index(): form = InputForm(request.form) if request.method == 'POST': # and form.validate(): arg_names = inspect.getargspec(compute).args kwargs = { name: getattr(form, name).data for name in arg_names if hasattr(form, name) } result = compute(**kwargs) else: result = None if result: # result must be transformed to HTML and inserted as a # string in the generic view.html file result = render_template('view_results.html', result=result) return render_template('view.html', form=form, result=result)
def my_post(): form = InputForm(request.form) if request.method == 'POST': identity = form.ID.data sp1s = form.Span1_start.data sp1e = form.Span1_end.data sp2s = form.Span1_start.data sp2e = form.Span2_end.data img, rem, lat, lon = sn.get_image(id=identity, sp1s=sp1s, sp1e=sp1e, sp2s=sp2s, sp2e=sp2e) else: return render_template('my.html', form=form) dt1 = str(sp1e) dt2 = str(sp2e) query = { 'plot_id': identity, 'lat': lat, 'lon': lon, 'remarks': rem, 'source_image_date': dt1, 'target_image_date': dt2 } req = requests.get( 'https://egujforestgis.gujarat.gov.in/forest_mobile_web_test/change_detect', params=query, verify=False) url = req.url print(url) retval, buffer = cv2.imencode('.png', img) # return render_template('my.html', form=form, img=img) png_as_text = base64.b64encode(buffer) response = make_response(buffer.tobytes()) response.headers['Content-Type'] = 'image/png' return response
def upload_file(): form = InputForm(request.form) filename = None # default if request.method == 'POST': # Save uploaded file on server if it exists and is valid if request.files: file = request.files[form.filename.name] if file and allowed_file(file.filename): # Make a valid version of filename for any file ystem #filename = secure_filename(file.filename) filename = file.filename file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) elif file and not allowed_file(file.filename): flash('Only txt files are accepted!') return redirect(request.url) elif file not in request.files: flash('Please include a file for upload!') return redirect(request.url) standardResults = None sampleResults = None if request.form.get('goldenToad') == 'on': runType = GoldenToad(filename) standardResults = runType.fillStandardsDataframe().to_html( index=False, classes='table') sampleResults = runType.fillSamplesDataframe().to_html( index=False, classes='table') elif request.form.get('notGoldenToad') == 'on': runType = BcaCalculator(filename) standardResults = runType.fillStandardsDataframe().to_html( index=False, classes='table') sampleResults = runType.fillSamplesDataframe().to_html( index=False, classes='table') return render_template('index.html', tables=[standardResults, sampleResults], form=form, standardResults=standardResults, sampleResults=sampleResults)
def view(): form = InputForm(request.form) return str(form.A.data)
def index(): form = InputForm(CombinedMultiDict((request.files, request.form))) filename = None # default if request.method == 'POST': print 'values', request.form['submit'] if (request.form['submit'] == 'Compute') and form.validate_on_submit(): print 'values', request.form['submit'] print 'validate', form.validate_on_submit() for file in glob.glob( os.path.join(app.config['UPLOAD_FOLDER'], "*.grd")): os.remove(file) output_full = './downloads/out.grd' if os.path.isfile('./downloads/out.grd'): os.remove(output_full) filenames = [] MinMax = [] sigma = [] for field in form: # Make local variable (name field.name) if (not ('filename' in field.name) and field.name != 'csrf_token'): # exec('%s = ''%s''' % (field.name, field.data)) if ('MinMax' in field.name): MinMax.append(field.data) if ('sigma' in field.name): sigma.append(field.data) elif ('filename' in field.name): file = request.files[field.name] if file: # Make a valid version of filename for any file ystem print 'load', file.filename # filenames.append( secure_filename(file.filename) ) file.save( os.path.join(app.config['UPLOAD_FOLDER'], secure_filename(file.filename))) filenames.append( os.path.join(app.config['UPLOAD_FOLDER'], secure_filename(file.filename))) print 'MinMax', MinMax result = compute(filenames, MinMax, sigma) data_masked = result[3] header = result[4] data_masked[isnan(data_masked)] = 1.70141E+038 np.savetxt(output_full, data_masked, header=header, newline='\n', fmt='%1.7f', comments='') elif (request.form['submit'] == 'Save') and os.path.isfile('./downloads/out.grd'): print 'exist output', os.path.isfile('./downloads/out.grd') print 'values', request.form['submit'] result = None return send_from_directory(directory=app.config['DOWNLOAD_FOLDER'], filename='out.grd') else: result = None else: print 'validate', form.validate_on_submit() result = None return render_template('view.html', form=form, result=result)