def main(): print "in main()" tornado.options.parse_command_line() application.listen(options.port) try: tornado.ioloop.IOLoop.instance().start() except KeyboardInterrupt: tornado.ioloop.IOLoop.instance().stop()
def main(port): #tornado.options.parse_command_line() application.listen(port) print("Development server is running at http://127.0.0.1:%s" % port) print("Quit the server with Control-C") tornado.ioloop.IOLoop.instance().start() #main(8888)
def main(): method = sys.argv[1] argv = sys.argv[2:] if method == 'run': if len(sys.argv) > 2: port = int(sys.argv[2]) else: port = 8000 application.listen(port) ioloop = tornado.ioloop.IOLoop.instance() ioloop.start() elif method == 'shell': run_shell(argv)
#coding:utf-8 import tornado.ioloop import sys from application import application PORT = '8080' if __name__ == "__main__": if len(sys.argv) > 1: PORT = sys.argv[1] application.listen(PORT) print 'The port is:', PORT print 'Quit the server with CONTROL-C' tornado.ioloop.IOLoop.instance().start()
#coding:utf-8 import tornado.ioloop import sys from model import entity from handlers import index from application import application from lib import onlineldavb PORT = '8888' if __name__ == "__main__": if len(sys.argv) > 1: PORT = sys.argv[1] application.listen(PORT) print ('Development server is running at http://127.0.0.1:%s/' % PORT) print ('Quit the server with CONTROL-C') tornado.ioloop.IOLoop.instance().start()
#coding:utf-8 import tornado.ioloop import tornado.options from tornado.options import define, options define("port", default=8000, help="run on the given port", type=int) from application import application if __name__ == "__main__": tornado.options.parse_command_line() application.listen(options.port) print 'Development server is running at http://127.0.0.1:%s/' % options.port print 'Quit the server with CONTROL-C' tornado.ioloop.IOLoop.instance().start()
# -*- coding: utf-8 -*- """启动web server""" import logging from application import application from tornado.options import define, options # tornado没有的命令要通过define定义(logging等命令有了) define("httpport", 8880, help="define http port", type=int) define("tcpport", 8881, help="define tcp port", type=int) if __name__ == "__main__": options.logging = "debug" # *1 options.log_file_prefix = "var/log/test_log@8880_8881.log" options.parse_command_line() from share import ioloop from tcpserver.server import add_handler # 启动http服务 application.listen(options.httpport) logging.debug("http server:%s", options.httpport) # 启动tcp服务 add_handler(options.tcpport) logging.debug("tcp server:%s", options.tcpport) # IO 循环 ioloop.start() # python main.py --httpport=8880 --tcpport=8881 --logging=warning # 这里的会覆盖 *1行的
# -*- coding:utf-8 -*- ''' Author: Bu Kun E-mail: [email protected] CopyRight: http://yunsuan.org ''' import sys import tornado.autoreload import tornado.ioloop import tornado.locale from application import application from config import PORT if __name__ == "__main__": tornado.locale.load_gettext_translations('locale', 'yunsuan') if len(sys.argv) > 1: application.listen( sys.argv[1] ) else: application.listen(PORT) print('Server is running at http://127.0.0.1:{0}/'.format(PORT)) print('Quit the server with CONTROL-C') tornado.ioloop.IOLoop.instance().start()
#coding:utf-8 import tornado.ioloop import tornado.options from tornado.options import define, options define("port", default=8011, help="run on the given port", type=int) from application import application if __name__ == "__main__": tornado.options.parse_command_line() application.listen(options.port) print 'Development server is running at http://127.0.0.1:%s/' % options.port print 'Quit the server with CONTROL-C' tornado.ioloop.IOLoop.instance().start()
def main(): tornado.options.parse_command_line() logging.info("Starting Tornado web server on http://127.0.0.1:%s" % options.port) application.listen(options.port) tornado.ioloop.IOLoop.instance().start() print 'Quit the server with CONTROL-C'
#!/usr/bin/env python # -*- coding: utf-8 -*- import tornado.ioloop import tornado.web from application import application if __name__ == "__main__": application.listen(8090) tornado.ioloop.IOLoop.current().start()
from tornado.ioloop import IOLoop from application import application from utils.log import visitlog from utils.zeus import read_constants_file PORT = int(read_constants_file('port.secret')) if __name__ == "__main__": visitlog.info("***************************************************") application.listen(PORT, xheaders=True) IOLoop.current().start()