我使用以下命令启动脚本:
cherryd -c tiny.cfg -i tiny
但我无法阅读应用配置设置(数据库)。有什么问题?
tiny.py
import cherrypy
class HelloWorld:
def index(self):
return "Hello world!"
index.exposed = True
app = cherrypy.tree.mount(HelloWorld(), '/')
print 'app.config', app.config
print 'cherrypy.config', cherrypy.config
tiny.cfg
[global]
server.socket_host: "0.0.0.0"
[database]
driver: "mysql"
host: "localhost"
答案 0 :(得分:1)
尝试将配置传递给tree.mount调用:
app = cherrypy.tree.mount(HelloWorld(), '/', 'tiny.cfg')