第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

http://localhost:8080/article訪問時報“AttributeError: No template named hello2”

下面是我寫的代碼,煩請幫忙看下是哪里的問題?
1.code.py

import web

import MySQLdb

import MySQLdb.cursors



render =web.template.render('templates')

urls = (

? ? '/article', 'article',

? ? '/index', 'index',

? ? '/blog/\d+', 'blog',

? ? '/(.*)', 'hello',

)


app = web.application(urls, globals())


class index:

? ? def GET(self):

? ? ? ? query = web.input()

? ? ? ? return query

? ? ? ??

class blog:

? ? def POST(self):

? ? ? ? data = web.input()

? ? ? ? return data

? ? ? ??

? ? def GET(self):

? ? ? ? return web.ctx.env

? ? ? ?

class hello:

? ? def GET(self, name):

? ? ? ? return render.hello2(name)

? ? ?

class article:

? ? def GET(self):

? ? ? ? conn = MySQLdb.connect(host='localhost', user='root', password='root', db='test', port=3306, cursorclass=MySQLdb.cursors.DictCursor)

? ? ? ? cur = conn.cursor()

? ? ? ? cur.execute('select * from articles')

? ? ? ? r = cur.fetchall()

? ? ? ? cur.close()

? ? ? ? conn.close()

? ? ? ? print(r)

? ? ? ? return render.article(r)

? ? ? ??

if __name__ == "__main__": app.run()


2.hello2.html

$def with(name)

<html>

<head>

<title>hello</title>

</head>

<body>

<h1>POST</h1>

<form action="/blog/123" method="POST">

<input type="text" name="username" value="$name"/>

<input type="password" name="password" value=""/>

<input type="submit" value="submit">

</form>

</body>

</html>


3.article.html

$def with(r)

<html>

? ? <head>

? ? ? ? <meta charset="utf-8"/>

? ? ? ? <title>article</title>

? ? </head>

? ? <body>

? ? ? ? <h1>文章列表</h1>

? ? ? ? <ul>

$for l in r:

? ? <li>$l.get('aid') => $l.get('title')</li>

</ul>

? ? </body>

</html>


4.模板目錄
http://img1.sycdn.imooc.com//619c922b00014d5312050295.jpg

正在回答

舉報

0/150
提交
取消

http://localhost:8080/article訪問時報“AttributeError: No template named hello2”

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號