flask框架
This commit is contained in:
parent
547ada4b35
commit
777cdb2da8
|
|
@ -8,6 +8,6 @@
|
|||
**/*.conda*/*
|
||||
**/*cache*/*
|
||||
.vscode/*
|
||||
*使用指南*.html
|
||||
**/*test*
|
||||
*html
|
||||
*.sh
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Flask App</title>
|
||||
<style>
|
||||
.checkbox-container {
|
||||
margin-right: 20px; /* Adjust the value to increase or decrease the horizontal spacing */
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello World</h1>
|
||||
<form method="POST">
|
||||
<div style="display: flex;">
|
||||
<div class="checkbox-container">
|
||||
<input type="checkbox" name="checkbox" value="Checkbox 1"> Checkbox 1<br>
|
||||
<input type="checkbox" name="checkbox" value="Checkbox 2"> Checkbox 2<br>
|
||||
<input type="checkbox" name="checkbox" value="Checkbox 3"> Checkbox 3<br>
|
||||
</div>
|
||||
<div>
|
||||
<input type="radio" name="radiobox" value="Radiobox 1"> Radiobox 1<br>
|
||||
<input type="radio" name="radiobox" value="Radiobox 2"> Radiobox 2<br>
|
||||
<input type="radio" name="radiobox" value="Radiobox 3"> Radiobox 3<br>
|
||||
<input type="radio" name="radiobox" value="Radiobox 4"> Radiobox 4<br>
|
||||
</div>
|
||||
</div>
|
||||
<input type="submit" value="提交">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Result</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Selected Checkboxes:</h2>
|
||||
<ul>
|
||||
{% for checkbox in checkboxes %}
|
||||
<li>{{ checkbox }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<h2>Selected Radioboxes:</h2>
|
||||
<ul>
|
||||
{% for radiobox in radioboxes %}
|
||||
<li>{{ radiobox }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue