Created
March 18, 2017 14:50
-
-
Save zh012/ea1d8a6cfaadc3ff898ce34b70043801 to your computer and use it in GitHub Desktop.
ironpython launch browser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import System | |
| import Microsoft | |
| import Microsoft.Win32.Registry as Registry | |
| from System.Threading import Thread, ThreadStart | |
| def get_default_browser(): | |
| try: | |
| key = Registry.ClassesRoot.OpenSubKey("HTTP\shell\open\command", False) | |
| browser = key.GetValue(None).ToString().ToLower() | |
| if browser.startswith('"'): | |
| browser = browser.split('"')[1] | |
| else: | |
| browser = browser.split()[0] | |
| browser = browser.strip() | |
| return browser | |
| finally: | |
| if key: | |
| key.Close() | |
| def launch_default_browser(destination): | |
| p = System.Diagnostics.Process() | |
| p.StartInfo.FileName = get_default_browser() | |
| p.StartInfo.Arguments = "%s" % destination | |
| p.Start() | |
| return p | |
| import bottle | |
| @bottle.route('/') | |
| def home(): | |
| return "Extract the WeChat Info" | |
| def runHttpServer(): | |
| bottle.run(host='localhost', port=9876) | |
| def startServer(): | |
| thread = Thread(ThreadStart(runHttpServer)) | |
| thread.Start() | |
| return thread | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment