Skip to content

Instantly share code, notes, and snippets.

@yeyuguo
Last active November 30, 2016 01:24
Show Gist options
  • Save yeyuguo/d3743be34b19d1d9f4ff98718b0e6bc1 to your computer and use it in GitHub Desktop.
Save yeyuguo/d3743be34b19d1d9f4ff98718b0e6bc1 to your computer and use it in GitHub Desktop.
一个调试 和 正式服务的server文件
import os,sys
from main import app,db
# app is flask: app = Flask(__name__)
def runServer(debug=True):
print '*'*20
try:
port = int(sys.argv[1])
except Exception,e:
print 'error:',e
port = 64320
print 'port is %s:'%port
if debug:
app.run(debug=True,host='0.0.0.0',port=port)
else:
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
import tornado.web
http_server = HTTPServer(WSGIContainer(app))
http_server.listen(port)
IOLoop.instance().start()
if __name__ == '__main__':
if not os.path.exists('db.sqlite'):
db.create_all()
runServer(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment