将变量传递给Python上的html文件(Passing variables to html file on Python)
我正在使用以下函数来执行简单的HTML视图:
import cherrypy
class index(object):
@cherrypy.expose
def example(self):
var = "goodbye"
index = open("index.html").read()
return index
我们的index.html文件是:
Hello, {var}!
如何将{var}变量从控制器传递给视图?
我正在使用CherryPy微框架来运行HTTP服务器而我没有使用任何模板引擎。
I'm using the following function to execute a simple HTML view:
import cherrypy
class index(object):
@cherrypy.expose
def example(self):
var = "goodbye"
index = open("index.html").read()
return index
Our index.html file is:
Hello, {var}!
How can I pass the {var} variable to the view from my controller?
I'm using CherryPy microframework to run