MAI/LabWork01/LoadDB.py

30 lines
686 B
Python
Raw Normal View History

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