I am using the following code (within Cherrypy) to open a file on the network share. (http://localhost:8080/g?filename=filename.docx) This seems to work fine, but when I open a file, for example a Word document, Word is opening behind the current browser window. How to open a link and focus on the window?
import os
import cherrypy
import webbrowser
class StringGenerator(object):
@cherrypy.expose
def index(self):
return "Hello world!"
@cherrypy.expose
def g(self, filename):
webbrowser.open(r'\\computer\share\filename.docx', new=2, autoraise=True)
if __name__ == '__main__':
cherrypy.quickstart(StringGenerator())