MAI/LabWork01/LoadDB.py
2023-09-25 20:43:20 +04:00

30 lines
686 B
Python

from flask import Flask, request, render_template
import numpy as np
app = Flask(__name__)
degree = 3
@app.route("/")
def home():
return render_template('main_page.html')
@app.route("/calculateCube", methods=['GET','POST'])
def numtext():
data = request.args
#проверка на int или float
if data['number']:
if data['number'].isdigit():
result = np.power(int(data['number']), degree)
else:
result = np.power(float(data['number']), degree)
return render_template('main_page.html', context=result)
else:
return render_template('main_page.html')
if __name__=="__main__":
app.run(debug=True)