2023-09-25 20:43:20 +04:00
|
|
|
from flask import Flask, request, render_template
|
|
|
|
import numpy as np
|
2023-09-14 17:46:46 +04:00
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
2023-09-25 20:43:20 +04:00
|
|
|
degree = 3
|
2023-09-23 14:27:08 +04:00
|
|
|
|
2023-09-14 17:46:46 +04:00
|
|
|
@app.route("/")
|
|
|
|
def home():
|
2023-09-25 20:43:20 +04:00
|
|
|
return render_template('main_page.html')
|
2023-09-14 17:46:46 +04:00
|
|
|
|
2023-09-25 20:43:20 +04:00
|
|
|
@app.route("/calculateCube", methods=['GET','POST'])
|
2023-09-14 17:46:46 +04:00
|
|
|
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-23 14:27:08 +04:00
|
|
|
|
2023-09-25 20:43:20 +04:00
|
|
|
return render_template('main_page.html', context=result)
|
|
|
|
else:
|
|
|
|
return render_template('main_page.html')
|
2023-09-14 17:46:46 +04:00
|
|
|
|
|
|
|
if __name__=="__main__":
|
|
|
|
app.run(debug=True)
|
2023-09-14 14:30:19 +04:00
|
|
|
|