def __call__(self, app, host, port, use_debugger, use_reloader): # override the default runserver command to start a Socket.IO server if use_debugger is None: use_debugger = app.debug if use_debugger is None: use_debugger = True if use_reloader is None: use_reloader = app.debug socketio.run(app, host=host, port=port, debug=use_debugger, use_reloader=use_reloader, **self.server_options)
from application import app, socketio if __name__ == '__main__': socketio.run(app, debug=True)
def run_server(): app.debug = True socketio.run(app, host=app.config.get("SERVER_HOST"), port=app.config.get("SERVER_PORT"), use_reloader=True)
#!flask/bin/python from application import app, socketio socketio.run(app, host="0.0.0.0", port=int("8500"), debug=True)
""" This script runs the MoustacheMakerApplication application using a development server. """ from os import environ from application import create_app, socketio app = create_app() if __name__ == '__main__': HOST = environ.get('SERVER_HOST', 'localhost') try: PORT = int(environ.get('SERVER_PORT', '5555')) except ValueError: PORT = 5555 socketio.run(HOST, PORT)
from application import create_app, socketio app = create_app() if __name__ == '__main__': socketio.run(app)
# Run a test server. from application import app, socketio socketio.run(app, host='0.0.0.0', port=8080, debug=True)
def runserver(): socketio.run(app)
import eventlet from application import create_app, socketio app = create_app() if __name__ == "__main__": eventlet.monkey_patch() socketio.run(app, host=app.config['SERVER_HOST'], port=app.config['SERVER_PORT'], use_reloader=False)
from application import manage, socketio from flask_script import Server from www import app manage.add_command( 'runserver', Server(host='0.0.0.0', port=app.config['SERVER_PORT'], use_debugger=True, threaded=True)) manage.add_command( 'runserver', socketio.run(app=app, host='0.0.0.0', port=app.config['SERVER_PORT'])) # 新加入的代码,重写manager的run命令 def main(): manage.run() if __name__ == '__main__': try: import sys sys.exit(main()) except Exception as e: import traceback traceback.print_exc() # set ops_config=local&&python manager.py runserver
from application import app, socketio app.config[ 'SEND_FILE_MAX_AGE_DEFAULT'] = 0 # DONT LET BROWSER CACHE ANYTHING! -- For development only! app.secret_key = 'development' # change when out of development! #################################################################################### # attempt to clear cache so static files reload... doesn't seem to work all the time! @app.after_request def add_header(r): """ Add headers to both force latest IE rendering engine or Chrome Frame, and also to cache the rendered page for 10 minutes. """ r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate" r.headers["Pragma"] = "no-cache" r.headers["Expires"] = "0" r.headers['Cache-Control'] = 'public, max-age=0' return r #################################################################################### if __name__ == '__main__': print("running... ") port = int(os.environ.get("PORT", 5000)) print("port is:") print(port) socketio.run(app, host='0.0.0.0', port=port)
import os from application import app, socketio if __name__ == "__main__": socketio.run(app, host='0.0.0.0', port=5000)
#!flask/bin/python from application import application, socketio if __name__ == '__main__': socketio.run(application, host="0.0.0.0", debug=True)
from application import create_app, socketio app = create_app('default') if __name__ == '__main__': socketio.run(app, debug=True, port=5050)