小編這次要給大家分享的是詳解Python中Flask框架如何實(shí)現(xiàn)簡單加法工具,文章內(nèi)容豐富,感興趣的小伙伴可以來了解一下,希望大家閱讀完這篇文章之后能夠有所收獲。
主程序mainaddfunc.py
from flask import Flask, render_template, request, url_for from add import * app = Flask(__name__) @app.route('/', methods=['GET']) def home(): return render_template('index.html') @app.route('/', methods=['POST']) def add(): a = request.form['adder1'] b = request.form['adder2'] try: a = float(a) b = float(b) result = sum_function(a, b) return render_template('index.html', result=result, var1=a, var2=b) except: return render_template('index.html', message='inputs false!!!', var1=a, var2=b) if __name__ == '__main__': app.run(port=8080)