from core.app import app # from flask_bootstrap import Bootstrap if __name__ == '__main__': app.config['SECRET_KEY'] = 'cBRzmuqekeC7YtvNr93tXyERbUfblgJv' app.run(debug=True)
from core.app import app # more here... if __name__ == '__main__': app.debug = True app.run(host='0.0.0.0')
def runserver(host, port): app.run(host, port)
from core.utils import * from micros.register import MicroService """ Initiating the application """ api.init_app(app) # Starting the web server if __name__ == '__main__': args = COMMAND_ARGS # SETTING LOG CONFIGURATION level = iif('LOG' in args and args['LOG'], args['LOG'], LOG_LEVEL) Logger._setup(path=CONF_DIR + os.sep + LOG_CONFIG_FILE_NAME, log_path=LOG_DIR, level=level) # REGISTERING MICRO SERVICES micros = iif('MICROS' in args, args['MICROS'], []) MicroService.register(micros) # APPLICATION SETUP port = iif('PORT' in args and args['PORT'], args['PORT'], APPLICATION_PORT) debug = iif('LOG' in args and args['LOG'] == 'DEBUG', True, False) ###################################################### # STARTING FLASK APPLICATION ###################################################### app.run(host=APPLICATION_HOST, port=port, debug=debug) ######################################################
from core.app import app # more here... if __name__ == '__main__': app.run()
#!/usr/bin/env python3 from core.app import app from core.config import _cfg, _cfgi import os app.static_folder = os.path.join(os.getcwd(), "_static") if __name__ == "__main__": app.run(host=_cfg("debug-host"), port=_cfgi("debug-port"), debug=True)
"" This is a temporary file to patch over deploys - remove once working! """ from core.app import app if __name__ == "__main__": app.run()
""" run_local.py isort:skip_file """ import sys sys.path.append(".") sys.path.append("..") from core.app import app if __name__ == "__main__": try: app.run(host="0.0.0.0") except OSError as e: print("Server is already running somewhere else.")
# 由于sanic 中间件为全局处理,不支持跟随蓝图独立处理,所以将中间件写在了入口文件中 @app.middleware('request') async def check(request): # 根据请求路径,找到请求对应的接口前缀 prefix = None rep = None for i in c.PREFIX: if request.headers['host'] + c.PREFIX[i] in request.url: prefix = c.PREFIX[i] # 处理后台接口中间处理 if prefix == '/api/v1/be/': rep = middleHandle(request, prefix, 'black', c.BLACK_AUTH, True, c.ANONYMOUS_API) # 处理前台接口中间处理 elif prefix == '/api/v1/fe/': rep = middleHandle(request, prefix, 'white', c.WHITE_AUTH, False) # 处理非法请求地址 else: rep = fail('请求路径不合法', 404, 404) # 处理结果为非空,则直接return if rep: return rep app.blueprint(fe.bp) app.blueprint(be.bp) if __name__ == '__main__': app.run(host='0.0.0.0', port=c.PORT)
def run_dev(): port = int(os.environ.get('PORT', 5000)) app.run(host='localhost', port=port, debug=True)
from core.app import app from flask import Flask from core import routes if __name__ == "__main__": # Only for debugging while developing app.run(host='0.0.0.0', debug=True, port=80)
from core.app import app from config import HOST, PORT if __name__ == "__main__": app.run(host=HOST, port=PORT)
from core.app import app if __name__ == '__main__': app.run('0.0.0.0', debug=True, port='8123')
async def check(request): # 根据请求路径,找到请求对应的接口前缀 prefix = None rep = None for i in c.PREFIX: if request.headers['host'] + c.PREFIX[i] in request.url: prefix = c.PREFIX[i] # 处理后台接口中间处理 if prefix == '/api/v1/be/': rep = middleHandle(request, prefix, \ 'black', c.BLACK_AUTH, True, c.ANONYMOUS_API) # 处理前台接口中间处理 elif prefix == '/api/v1/fe/': rep = middleHandle(request, prefix, 'white', c.WHITE_AUTH, False) # 处理非法请求地址 else: rep = fail('请求路径不合法', 404, 404) # 处理结果为非空,则直接return if rep: return rep app.blueprint(be.bp) app.blueprint(fe.bp) if __name__ == "__main__": app.run(host="0.0.0.0", port=9000)
from core.app import app app.run(debug=True, host='0.0.0.0')
from core.app import app if __name__ == "__main__": app.run(host='0.0.0.0', debug=False)