我正在尝试制作一个分支预测器:
这是我在 app.py 中的代码:
import web
urls = (
'/hello','index'
)
app = web.application(urls,globals())
render = web.template.render('templates/', base='layout')
class index(object):
def GET(self):
return render.hello_form()
def POST(self):
form=web.input(name='nobody', rank=0)
branch=None
if form.rank<=4613:
branch = 'COE, ECE,IT,ICE,MPAE,BT'
if int(form.rank)<=7471 & int(form.rank)>4613:
branch='ECE,IT,ICE,MPAE,BT'
if int(form.rank)<=11325 & int(form.rank)>7471:
branch = 'IT,ICE,MPAE,BT'
if int(form.rank)<=16565 & int(form.rank)>11325:
branch='ICE,MPAE,BT'
if int(form.rank)<=17955 & int(form.rank)>16565:
branch='MPAE,BT'
if int(form.rank)<=20714 & int(form.rank)<17955:
branch='BT'
return render.index(branch=branch)
if __name__=='__main__':
app.run()
这是我的 html 文件 hello_form.html 中的代码
<h1>NSIt Branch Predictor for First Round</h1>
<form action='hello' method ='POST'>
Your Name: <input type = 'text' name = 'name'>
<br>
AIEEE Rank: <input type = 'text' name ='rank'>
<input type='submit'>
这是我在 index.html 中的代码:
$def with (branch)
branch: $branch
我有 layout.html 如下:
$def with (content)
<html>
<head>
<title> first python website</title>
</head>
<body>
$:content
</body>
</html>
但在输出中我得到:
branch: