CherryPy自帶Web(HTTP)服務(wù)器。 這就是為什么CherryPy是自包含的,允許用戶在獲取庫的幾分鐘內(nèi)運(yùn)行CherryPy應(yīng)用程序。
web server充當(dāng)應(yīng)用程序的網(wǎng)關(guān),在此幫助下,所有請求和響應(yīng)都保持跟蹤。
要啟動Web服務(wù)器,用戶必須進(jìn)行以下調(diào)用 -
cherryPy.server.quickstart()
internal engine of CherryPy的internal engine of CherryPy負(fù)責(zé)以下活動 -
該框架帶有自己的配置系統(tǒng),允許您參數(shù)化HTTP服務(wù)器。 配置的設(shè)置可以存儲在語法接近INI格式的文本文件中,也可以存儲為完整的Python字典。
要配置CherryPy服務(wù)器實例,開發(fā)人員需要使用設(shè)置的全局部分。
global_conf = {
'global': {
'server.socket_host': 'localhost',
'server.socket_port': 8080,
},
}
application_conf = {
'/style.css': {
'tools.staticfile.on': True,
'tools.staticfile.filename': os.path.join(_curdir, 'style.css'),
}
}
This could be represented in a file like this:
[global]
server.socket_host = "localhost"
server.socket_port = 8080
[/style.css]
tools.staticfile.on = True
tools.staticfile.filename = "/full/path/to.style.css"
更多建議: