新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:pythontornado如何更改代碼?
tornado基礎知識想必大家已經(jīng)學的差不多了。接下來小編會為大家?guī)砩晕⒂悬c難度的知識點??床欢目梢远鄬W幾遍。

創(chuàng)新互聯(lián)是一家專注于網(wǎng)站建設、網(wǎng)站設計與策劃設計,左云網(wǎng)站建設哪家好?創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設10年,網(wǎng)設計領域的專業(yè)建站公司;建站業(yè)務涵蓋:左云等地區(qū)。左云做網(wǎng)站價格咨詢:18982081108
眾所周知,網(wǎng)站是一個極其復雜的系統(tǒng),不可能只有一個靜態(tài)頁面。所以我們將上文的代碼做一下改變:
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
settings = {
'template_path':'template',
'static_path':'static',
}
def make_app():
return tornado.web.Application([
(r"/", MainHandler),
],**settings)
if __name__ == "__main__":
app = make_app()
app.listen(8888)
tornado.ioloop.IOLoop.current().start()
如上,我們添加了一個變量settings,但不要忘記在make_app后加上動態(tài)參數(shù)
template_path是你網(wǎng)頁模板的路徑,也就是你放網(wǎng)頁的地方
static_path是你網(wǎng)頁模板所需的css,js,圖片等存放的地方
以上就是python tornado更改代碼的方法。更多Python學習推薦:PyThon學習網(wǎng)教學中心。
網(wǎng)站名稱:創(chuàng)新互聯(lián)Python教程:pythontornado如何更改代碼?
標題URL:http://fisionsoft.com.cn/article/dhsdjih.html


咨詢
建站咨詢
