Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update app.py #460

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions visualizer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)
messages = []
port = [8000]

def send_msg(role, text):
try:
data = {"role": role, "text": text}
response = requests.post(f"http://127.0.0.1:{port[-1]}/send_message", json=data)
except:
logging.info("flask app.py did not start for online log")
response = requests.post(f"http://127.0.0.1:{port}/send_message", json=data) # Updated to use port directly
except Exception as e: # Improved error handling
logging.error(f"Error sending message: {e}")


@app.route("/")
Expand Down Expand Up @@ -63,6 +62,6 @@ def find_avatar_url(role):
parser = argparse.ArgumentParser(description='argparse')
parser.add_argument('--port', type=int, default=8000, help="port")
args = parser.parse_args()
port.append(args.port)
print(f"Please visit http://127.0.0.1:{port[-1]}/ for the front-end display page. \nIn the event of a port conflict, please modify the port argument (e.g., python3 app.py --port 8012).")
app.run(host='0.0.0.0', debug=False, port=port[-1])
port = args.port # Removed list and used port directly
print(f"Please visit http://127.0.0.1:{port}/ for the front-end display page. \nIn the event of a port conflict, please modify the port argument (e.g., python3 app.py --port 8012).")
app.run(host='0.0.0.0', debug=False, port=port) # Updated to use port directly