tornado中通用模版

第一:

1.Pycharm新建python项目(不是django项目),在项目下面直接新建server.py,内容如下:

2.安装tornado, pip install tornado

import tornado.web
import tornado.ioloop
import tornado.httpserver
import config

class Indexhandler(tornado.web.RequestHandler):
    def get(self,*args,**kwargs):
        self.write("good is luck")


if __name__=="__main__":
    app = tornado.web.Application([
        (r'/',Indexhandler)
    ])

    httpserver=tornado.httpserver.HTTPServer(app)
    httpserver.bind(config.options["port"])
    httpserver.start(1)
    tornado.ioloop.IOLoop.current().start()

第二:在项目下面新建一个配置文件config.py

options = {
    "port":9000
}

通过以上通用模版,可以改为跟django类似的项目结构,具体如下:

 

转载于:https://www.cnblogs.com/weilaibuxiangshuo/p/11016171.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值