Up until a few days ago, I could click a link to a locally stored .py file and Firefox would display it as a plain text file. This is what I want; e.g., it’s a way for me to organize notes, view examples I’ve created in the past, and like that.
Now when I click such a link, Firefox pops up a window asking me if I want to “Open with …” or “Save file”.
I installed Python 3.9.6 a few days ago, so I wondered if that was a coincidence. I don’t think it is, because I just went to another machine, where clicking a link to a .py file worked as desired, updated the Python on that machine, and now I’m seeing the same (unwanted) behavior. Therefore, I believe something might be going on with the Python installation process. However, it also seems to me like this should be something that I could fix in Firefox's settings somewhere.
I've tried a bunch of stuff suggested on Mozilla's pages, including deleting the handlers.json file in my Profile folder, running a full Refresh, and creating a new profile. None of these got me back to the old behavior. General Googling has not helped; most of the results are out of date, and/or advise installation of a Firefox extension (no longer checked for security holes by Mozilla).
Any ideas? Thanks in advance.
P.S. I've got a similar question posted on support.mozilla.org and discuss.python.org, and will update if I get any answers from either of those.
P.P.S. [ETA] Running on Windows 10 Pro, Firefox v90.0.2.
61 Answer
Not that many people seem to care, but just in case, for someone in the future …
When I didn’t find a solution to the above, I decided the least painful way to deal with the problem was to go into Settings > Applications in Firefox, and associate PY files with Emacs. So, now when I click a link to one of my local .py files, an Emacs window pops up, with that file in it.
Due to a typo a couple of days ago, I discovered another workaround: in the URL for the file, just append a dot, and then the proper file will open in the browser, as a plain text file, which is all I ever wanted. (Well, not all.) That is, this line in an HTML file will cause the file to open in a pop-up Emacs window …
<a href="file:///c:/some-dir/example.py">example.py</a>
… but this will open the same file, right in the browser (note the dot after the .py extension):
<a href="file:///c:/some-dir/example.py">example.py.</a>