0

I have an application that uses Chromium Embedded Framework. As an alternative for a setup where CEF is not usable (Python 3.10+ for example), I would like to fallback to a webbrowser to launch a local webapp.

Since I don't have any hook to pass data to the webapp without CEF, I tried to pass a configuration string through a GET parameter. I don't know why, but the query string disappears when I use one with the file:// protocol

example :

webbrowser.open_new_tab('https://google.com?foo=bar')  # this works.
webbrowser.open_new_tab('file:///c:/some/dir/somefile.html?foo=bar')  # this doesn't works.

on the second example. A browser window is open and the URL in the address bar is file:///c:/some/dir/somefile.html

Any idea?

8
  • Which webbrowser (and on what OS) is your fallback? I can't reproduce using Firefox or Google Chrome on Linux. In any case you may need this type of fallback involving an intermediate temporary file to redirect to your target. Commented Jun 9, 2022 at 1:47
  • I'm on windows 10. I fallback on the default browser, which is Chrome Version 102.0.5005.63 (Official Build) (64-bit) . Python 3.10.5
    – user2302957
    Commented Jun 9, 2022 at 1:48
  • You probably will need to create a temporary redirect file as per the linked fallback, or alternative, use # instead of ? to pass arguments (i.e. instead of using window.location.search, use window.location.hash). Commented Jun 9, 2022 at 1:52
  • Interesting. I indeed think I will have to embed Tornado or something similar in my code.
    – user2302957
    Commented Jun 9, 2022 at 1:54
  • A simple http.server might be enough if what you have is effective a single page client-side only webapp. Just run it long enough to serve everything the client requires and terminate it. Commented Jun 9, 2022 at 1:57

0