CherryPy 部署

2024-01-02 15:46 更新

CherryPy應用程序的部署被認為是一個非常簡單的方法,可以從Python系統(tǒng)路徑獲得所有必需的包。 在共享的Web托管環(huán)境中,Web服務器將駐留在前端,允許主機提供程序執(zhí)行篩選操作。 前端服務器可以是Apache或lighttpd 。

本節(jié)將介紹一些在Apache和lighttpd Web服務器后面運行CherryPy應用程序的解決方案。

cherrypy
def setup_app():
class Root:
@cherrypy.expose
def index(self):
   # Return the hostname used by CherryPy and the remote
   # caller IP address
return "Hello there %s from IP: %s " %
(cherrypy.request.base, cherrypy.request.remote.ip)
cherrypy.config.update({'server.socket_port': 9091,
   'environment': 'production',
   'log.screen': False,
   'show_tracebacks': False})
cherrypy.tree.mount(Root())
if __name__ == '__main__':
setup_app()
cherrypy.server.quickstart()
cherrypy.engine.start()


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號