flaskwebgui
flaskwebgui copied to clipboard
Edge browser preferred on windows
This may be more of a personal preference than a bug, but I noticed that on my Windows computer, FlaskUI would open the Edge browser. I was able to override this behavior by reordering this list of browsers to put chrome at the top:
windows_browser_paths = [
r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe",
r"C:\Program Files\Microsoft\Edge\Application\msedge.exe",
r"C:\Program Files\Google\Chrome\Application\chrome.exe",
r"C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe",
]
It may be notable that when I run webbrowser.get().name on my system it returns an empty string. webbrowser.open('google.com') opens Edge but webbrowser.open('https:\google.com') opens Chrome. Not sure if this is abnormal behavior. I did confirm that Google Chrome is set as the default browser and the default handler for HTTP and HTTPS protocols, but not for the "URL:microsoft-edge" protocol. This seems to be the normal state when Chrome is set as the default browser.
Interesting. It seems webbrowser.get().name is flaky and doesn't return the default browser all the time. If you know another alternative to find default browser on the OS please tell me.
You force it to use chrome if you provide your own func that finds browser path exe:
browser_path: str = func_that_finds_browser_path_return_str()
Checkout the source code, you can remove the other browser paths and keep just chrome.
I got hit by this too; Found some suggestions here on checking default browser via the registry:
https://stackoverflow.com/questions/19037216/how-to-get-a-name-of-default-browser-using-python
Hunting around the registry, this seems like a possibly promising approach to checking which browser is assocaited with https links: Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\https\UserChoice
..which on my machine gives me:
...whereas I get this from webbrowser:
Python 3.13.1 (tags/v3.13.1:0671451, Dec 3 2024, 19:06:28) [MSC v.1942 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import webbrowser
>>> webbrowser.get().name
''
...and one other thing to look for is some people don't have programfiles on drive C:\ but you can work around that with the %ProgramFiles% environment variable.
I've set chrome as first option in newer version.