Open browser in python app

Hello! I have setup a python discord bot which runs smoothly on a machine. One of its features is authenticating through oAuth and for that I have a button that redirects to the verification website. This works wonderfully on localhost but unfortunately not so much when hosted on the fly.io machine, as I’m getting the following errors in the monitor as soon as it tries to redirect.

[info] browser = webbrowser.get(browser_name)
[info] File "/usr/local/lib/python3.10/webbrowser.py", line 65, in get
[info] raise Error("could not locate runnable browser")
[info] webbrowser.Error: could not locate runnable browser

I get that the Docker container instance doesn’t have a browser so I’ve been trying to install one without success. It makes sense that a headless container wouldn’t be able to display GUI, but in this case I’d like the user’s own browser to open up the authentication webpage, not fly.io.

I’ve been cracking my head with this for some days now, please I need some help. This is my fly.toml configuration:

app = "discbot"
primary_region = "cdg"

[build]

[http_service]
  internal_port = 8080
  force_https = true
  auto_stop_machines = false
  auto_start_machines = true
  min_machines_running = 0
  processes = ["app"]

I guess noone can help? I’m really having a hard time getting used to docker and hosting a discord bot on fly.io. Any help would be warmly appreciated

Turns out I had to create a backend to support my needs and use fly like that instead of expecting it to open a website on the client’s side. Leaving this for posteriority, hope it helps someone in my position.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.