From 777cdb2da892944da4678f4bc1f24f8af953e7a0 Mon Sep 17 00:00:00 2001 From: "weiye.wang" Date: Mon, 6 May 2024 20:46:11 +0800 Subject: [PATCH] =?UTF-8?q?flask=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- 工具v4/flask框架.py | 14 ++++++++++++++ 工具v4/templates/index.html | 30 ++++++++++++++++++++++++++++++ 工具v4/templates/result.html | 20 ++++++++++++++++++++ 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 工具v4/flask框架.py create mode 100644 工具v4/templates/index.html create mode 100644 工具v4/templates/result.html diff --git a/.gitignore b/.gitignore index 200a40c8..6e8a356b 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,6 @@ **/*.conda*/* **/*cache*/* .vscode/* +*使用指南*.html **/*test* -*html *.sh diff --git a/工具v4/flask框架.py b/工具v4/flask框架.py new file mode 100644 index 00000000..05036216 --- /dev/null +++ b/工具v4/flask框架.py @@ -0,0 +1,14 @@ +from flask import Flask, render_template, request + +app = Flask(__name__) + +@app.route('/', methods=['GET', 'POST']) +def index(): + if request.method == 'POST': + selected_checkboxes = request.form.getlist('checkbox') + selected_radioboxes = request.form.getlist('radiobox') + return render_template('result.html', checkboxes=selected_checkboxes, radioboxes=selected_radioboxes) + return render_template('index.html') + +if __name__ == '__main__': + app.run(debug=True) \ No newline at end of file diff --git a/工具v4/templates/index.html b/工具v4/templates/index.html new file mode 100644 index 00000000..84cee40c --- /dev/null +++ b/工具v4/templates/index.html @@ -0,0 +1,30 @@ + + + + Flask App + + + +

Hello World

+
+
+
+ Checkbox 1
+ Checkbox 2
+ Checkbox 3
+
+
+ Radiobox 1
+ Radiobox 2
+ Radiobox 3
+ Radiobox 4
+
+
+ +
+ + \ No newline at end of file diff --git a/工具v4/templates/result.html b/工具v4/templates/result.html new file mode 100644 index 00000000..a2005d7d --- /dev/null +++ b/工具v4/templates/result.html @@ -0,0 +1,20 @@ + + + + Result + + +

Selected Checkboxes:

+ +

Selected Radioboxes:

+ + + \ No newline at end of file