tornado中通用模版

第一:python

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

2.安装tornado, pip install tornadodjango

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.pyapp

options = {
    "port":9000
}

经过以上通用模版,能够改成跟django相似的项目结构,具体以下:tornado

相关文章
相关标签/搜索