コード例 #1
0
def run() -> int:
    """
    Traktować to podobnie, jak `if __name__=="__main__"`. Funkcja uruchomiona powinna inicjalizować działające UI.
    Obiekt `main.Session` powinien być generowany dla każdego użytkownika. Wystarczy używać metod tego obiektu do interakcji z programem.

    :return: Exit code, -1 restartuje aplikację
    :rtype: int
    """
    webbrowser.open('http://127.0.0.1:5000', 2, autoraise=True)
    http_server = WSGIServer(app, host='127.0.0.1', port=5000)
    http_server.start()
コード例 #2
0
class APIServer:
    def __init__(self, ip, port, cwd, debug=False):
        self.ip = ip
        self.port = port
        self.cwd = cwd
        self.debug = debug
        Configuration.global_parameters = self.__dict__
        self.app = Flask(
            'WSGI-Flask Server on port: {port}'.format(port=self.port),
            template_folder='{}/vue_web_code/dist'.format(self.cwd),
            static_folder='{}/vue_web_code/dist'.format(self.cwd))
        self.http_server = None

        # Setup database and trigger Database.__enter__()
        self.database = Database()
        with self.database:
            pass

        # Start the API documentation services
        try:
            yaml.warnings({'YAMLLoadWarning': False})
        except Exception as error:
            print(error)
        Swagger(self.app, template=template)

        threading.Thread(target=self.run).start()

    def run(self):
        print('Starting WSGI-Flask Server on port: {port}'.format(
            port=self.port))
        print('API: http://{}:{}'.format(self.ip, self.port))
        self.app.config['JSON_SORT_KEYS'] = True
        self.app.config['TEMPLATES_AUTO_RELOAD'] = True
        self.app.config['SECRET_KEY'] = str(time.time())

        self.app.config['DEBUG'] = True
        self.app.config['SESSION_COOKIE_HTTPONLY'] = True
        self.app.config['REMEMBER_COOKIE_HTTPONLY'] = True
        self.app.config['SESSION_COOKIE_SAMESITE'] = 'Strict'
        self.app.debug = True
        self.app.register_blueprint(routes)

        self.http_server = WSGIServer(self.app, host='0.0.0.0', port=self.port)
        self.http_server.start()

    def stop(self):
        self.http_server.stop()
コード例 #3
0
ファイル: standalone.py プロジェクト: lsst-sqre/wfdispatcher
def standalone():
    """Standalone command for starting a server.
    """
    parser = argparse.ArgumentParser(
        description="Start Argo Workflow API Dispatch Server"
    )
    parser.add_argument(
        "-p", "--port", help="Server listening port", type=int, default=8080
    )
    parser.add_argument(
        "-b", "--bind-address", help="Server bind address", default="127.0.0.1"
    )
    parser.add_argument(
        "-m",
        "--mock",
        "--mock-authentication",
        action="store_true",
        help="Do not require a JWT; mock out authentication",
    )
    parser.add_argument(
        "--no-verify-signature",
        action="store_true",
        help="Do not verify JWT signature",
    )
    parser.add_argument(
        "--no-verify-audience",
        action="store_true",
        help="Do not verify JWT audience",
    )
    args = parser.parse_args()
    mock = args.mock
    v_s = True
    v_a = True
    if args.no_verify_signature:
        v_s = False
    if args.no_verify_audience:
        v_a = False
    server = Server(_mock=mock, verify_signature=v_s, verify_audience=v_a)
    httpd = WSGIServer(server.app, host=args.bind_address, port=args.port)
    httpd.start()
コード例 #4
0
 def handle(self, *args, **options):
     port = int(options['port'])
     server = WSGIServer(StaticFilesHandler(application), port=port)
     server.start()
コード例 #5
0
def entrypoint():
    from wsgiserver import WSGIServer
    port = int(os.environ.get("PORT", 8081))
    server = WSGIServer(app, host='127.0.0.1', port=port)
    server.start()
コード例 #6
0
ファイル: run.py プロジェクト: NaitLee/PHFS
            Config.port = arg
        else:
            if os.path.exists(arg):
                arg = os.path.abspath(arg).replace('\\', '/')
                if os.path.isdir(arg):
                    Config.base_path = arg
                    Account.accounts[''] = ('', arg)
                    print(I18n.get_string('base_path_set_to_0').format(arg))
                elif os.path.isfile(arg):
                    tempdir = tempfile.mkdtemp()
                    smartcopy(arg, tempdir)
                    Config.base_path = tempdir
                    Account.accounts[''] = ('', tempdir)
                    print(I18n.get_string('base_path_set_to_0_which_includes_copy_of_all_selected_files').format(tempdir))
    else:
        tempdir = tempfile.mkdtemp()
        for i in sys.argv[1:]:
            if os.path.exists(i):
                smartcopy(os.path.abspath(i), tempdir)
        Config.base_path = tempdir
        Account.accounts[''] = ('', tempdir)
        print(I18n.get_string('base_path_set_to_0_which_includes_copy_of_all_selected_files').format(tempdir))

from serverLib import PHFSServer
from wsgiserver import WSGIServer

if __name__ == '__main__':
    print(I18n.get_string('running_at_port_0').format(Config.port))
    server = WSGIServer(PHFSServer(), Config.host, int(Config.port))
    server.start()