Reputation: 13
I understand this a pretty basic and stupid question but I can't seem to find a straight answer on here. I want to open a local file named 'test.html' that is in the same folder as my program in the default web browser. How can I do this?
Upvotes: 1
Views: 801
Reputation: 38922
You can use python webbrowser library. https://docs.python.org/2/library/webbrowser.html
import os
import webbrowser
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
webbrowser.open('file://' + os.path.join(BASE_DIR, 'test.html'))
Upvotes: 1