Python 初学者程序员试图让烧瓶按钮在窗体上工作
我是一个初学者程序员,正在寻找代码方面的帮助。这是我第一次尝试。我现在只编程了一段时间,遇到了一个障碍。Python 初学者程序员试图让烧瓶按钮在窗体上工作,python,html,flask,Python,Html,Flask,我是一个初学者程序员,正在寻找代码方面的帮助。这是我第一次尝试。我现在只编程了一段时间,遇到了一个障碍。 这是我试图制作的按钮的烧瓶: from flask import Flask from flask import Flask, flash, redirect, render_template, request, session, abort, url_for import os app = Flask(__name__, static_url_path='/static')
这是我试图制作的按钮的烧瓶:
from flask import Flask
from flask import Flask, flash, redirect, render_template, request, session, abort, url_for
import os
app = Flask(__name__, static_url_path='/static')
@app.route('/home', methods=['POST', 'GET'])
def run_home():
if request.method == 'POST':
if request.form['bob'] == 'home':
pass
return redirect('home', code=302, Response=None)
elif request.method == 'GET':
return render_template('home.html', form=form)
下面是与上面的烧瓶关联的html。我需要帮助使按钮正常工作,但我卡住了。我试图使用一个表格来排列链接到不同页面的按钮。有人能帮我弄清楚怎么做吗
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>Home Page</title>
<meta charset="UTF-8">
<meta name="description" content="List of Comics">
<meta name="author" content="Zach">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<h1 align="center">List of Comics</h1>
<br />
</head>
<header>
<table cellspacing="10">
<tr>
<td><form method ="post" name="bob" action="url_for('home')}}" class="buttons to new page" id="home"><input type="submit" value="Home" name="Home"></form></td>
<td><form method ="post" name="bob" action="url_for('books')}}" class="buttons to new page" id="books"><input type="submit" value="Books" name="Books"></form></td>
<td><form method ="post" name="bob" action="url_for('comics')}}" class="buttons to new page" id="issues"><input type="submit" value="Issues" name="Issues"></form></td>
<td><form method ="post" name="bob" action="url_for('bio')}}" class="buttons to new page" id="bio"><input type="submit" value="Biography" name="Biography"></form></td>
</tr>
</table>
</header>
<body>
<a href="books.html"><h2 align="center">Books</h2></a>
<br />
<p align="center">These are books containing collections of issues.</p>
<a href="comics.html"><h2 align="center">Issues</h2></a>
<br />
<p align="center" a href="comics.html">These are individual issues.</p>
</body>
<footer>
<table cellspacing="10">
<tr><form method ="post" name="bob" action="/home" class="buttons to new page">
<td><input type="submit" value="Home" name="Home" formaction="/home.html" /></td>
<td><input type="submit" value="Books" name="Books" formaction="/comics.html" /></td>
<td><input type="submit" value="Issues" name="Issues" formaction="/issues.html" /></td>
<td><input type="submit" value="Biography" name="Biography" formaction="/bio.html" /></td>
</form></tr>
</table>
<p align="right">Date/Time: <span id="datetime"></span></p>
<script>
var dt = new Date();
document.getElementById("datetime").innerHTML = dt.toLocaleString();
</script>
</footer>
</html>
主页
漫画目录
这些是包含问题集合的书籍
这些都是单独的问题
日期/时间:
var dt=新日期();
document.getElementById(“datetime”).innerHTML=dt.toLocalString();
谢谢您的帮助。您可以创建
元素,而不是使用表单。如果你想让每个按钮都放在某个地方,你可以把它们放在
希望有帮助 你能再具体一点吗?哪些按钮不起作用?他们是没有反应还是导致了错误?检查您的终端,如果您试图使此按钮链接到另一个页面,请包含回溯。作为旁注,您的html无效,因为
和
应该在
中。感谢您的帮助。我让它与一些调整的烧瓶和html代码与您的标签帮助一点工作。随时!祝你的事业好运。:-)
<a href="/home"><button value="Home"></button></a>
<a href="/books"><button value="Books"></button></a>
<a href="/issues"><button value="Issues"></button></a>
<a href="/biography"><button value="Biography"></button></a>