您现在的位置是:课程教程文章
python tornado如何更改代码?
2023-12-18 16:49课程教程文章 人已围观
-
白帽子黑客编程技巧:Python编程掌握与网
白帽子黑客编程技巧:Python编程掌握与网注、课前说明 1、一对一答疑请加讲师微信:ihaha12 2、本课程系讲师原创,请自... -
Javaweb网站后台管理系统(集成公司和商城
Javaweb网站后台管理系统(集成公司和商城主要讲解基于javaweb的后台管理系统:集成网站后台和商城后台 主要讲解各个模... -
Python编程基础入门
Python编程基础入门课程概述 【开发课程目的】 随着人工智能时代到来,人们的工作、生活和学习... -
1小时用python开发单词查询系统
1小时用python开发单词查询系统本课程带领大家自主开发一款python应用 需要大家具备python的基础知识 本课程可...
tornado基础知识想必大家已经学的差不多了。接下来小编会为大家带来稍微有点难度的知识点。看不懂的可以多学几遍。
众所周知,网站是一个极其复杂的系统,不可能只有一个静态页面。所以我们将上文的代码做一下改变:
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后加上动态参数
template_path是你网页模板的路径,也就是你放网页的地方
static_path是你网页模板所需的css,js,图片等存放的地方
以上就是python tornado更改代码的方法。更多Python学习推荐:PyThon学习网教学中心。
课程教程:python tornado如何更改代码?下一篇:没有了