diff --git a/aiserver.py b/aiserver.py index b5704e9d..7d9fc87c 100644 --- a/aiserver.py +++ b/aiserver.py @@ -725,6 +725,7 @@ parser = argparse.ArgumentParser(description="KoboldAI Server") parser.add_argument("--remote", action='store_true', help="Optimizes KoboldAI for Remote Play") parser.add_argument("--ngrok", action='store_true', help="Optimizes KoboldAI for Remote Play using Ngrok") parser.add_argument("--host", action='store_true', help="Optimizes KoboldAI for Remote Play without using a proxy service") +parser.add_argument("--port", type=int, help="Specify the port on which the application will be joinable") parser.add_argument("--model", help="Specify the Model Type to skip the Menu") parser.add_argument("--path", help="Specify the Path for local models (For model NeoCustom or GPT2Custom)") parser.add_argument("--cpu", action='store_true', help="By default unattended launches are on the GPU use this option to force CPU usage.") @@ -5179,16 +5180,17 @@ def send_debug(): pass emit('from_server', {'cmd': 'debug_info', 'data': debug_info}, broadcast=True) - + #==================================================================# # Final startup commands to launch Flask app #==================================================================# print("", end="", flush=True) if __name__ == "__main__": + port = args.port if "port" in args else 5000 print("{0}\nStarting webserver...{1}".format(colors.GREEN, colors.END), flush=True) # Start Flask/SocketIO (Blocking, so this must be last method!) - + #socketio.run(app, host='0.0.0.0', port=5000) if(vars.host): if(args.ngrok): @@ -5196,24 +5198,26 @@ if __name__ == "__main__": cloudflare = _run_ngrok() elif(args.remote): from flask_cloudflared import _run_cloudflared - cloudflare = _run_cloudflared(5000) + cloudflare = _run_cloudflared(port) if(args.ngrok or args.remote): with open('cloudflare.log', 'w') as cloudflarelog: cloudflarelog.write("KoboldAI has finished loading and is available at the following link : " + cloudflare) print(format(colors.GREEN) + "KoboldAI has finished loading and is available at the following link : " + cloudflare + format(colors.END)) else: - print("{0}Webserver has started, you can now connect to this machine at port 5000{1}".format(colors.GREEN, colors.END)) + print("{0}Webserver has started, you can now connect to this machine at port 5000{1}" + .format(colors.GREEN, colors.END)) vars.serverstarted = True - socketio.run(app, host='0.0.0.0', port=5000) + socketio.run(app, host='0.0.0.0', port=port) else: import webbrowser - webbrowser.open_new('http://localhost:5000') - print("{0}Server started!\nYou may now connect with a browser at http://127.0.0.1:5000/{1}".format(colors.GREEN, colors.END)) + webbrowser.open_new('http://localhost:{0}'.format(port)) + print("{0}Server started!\nYou may now connect with a browser at http://127.0.0.1:{1}/{2}" + .format(colors.GREEN, port, colors.END)) vars.serverstarted = True if args.unblock: - socketio.run(app, port=5000, host='0.0.0.0') + socketio.run(app, port=port, host='0.0.0.0') else: - socketio.run(app, port=5000) + socketio.run(app, port=port) else: print("{0}\nServer started in WSGI mode!{1}".format(colors.GREEN, colors.END), flush=True)