2015-12-20 28 views
1

我正在使用web.py框架創建一個簡單的網站。但是當我跑網站時,它給了模板錯誤。模板錯誤,同時使用python創建一個簡單的網站

我的HTML文件代碼

def with (greeting) 
<html> 
<head> 
<title> "This is a web project"</title> 
<body> 
<H1>"Yoyo honey singh"</H1> 
<H6>greeting<H6> 
</body> 
</head> 
</html> 

我的Python文件中的代碼

import web 

urls = ("/","Index") 

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

render = web.template.render("\templates") 

class Index: 
    def GET(self): 
     greeting = "HELLO WORLD" 
     return render.index(greeting = greeting) 

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

我放置在模板文件夾中的index.html文件和Python腳本在bin文件夾。目錄結構就像

d:\網站 網站 NAME 初始化的.py 斌 app.py 測試 初始化的.py 文檔 模板

回答

1

按照documentation你應該在模板中的每個python語句之前放置一個$。因此第一個文件變成了:

​​
相關問題