MCPcopy Create free account
hub / github.com/EasyIME/PIME / launch_browser

Method launch_browser

python/input_methods/chewing/config_tool.py:259–273  ·  view source on GitHub ↗
(self, tool_name)

Source from the content-addressed store, hash-verified

257 self.port = 0
258
259 def launch_browser(self, tool_name):
260 user_html = """<html>
261 <form id="auth" action="http://127.0.0.1:{PORT}/login/{PAGE_NAME}" method="POST">
262 <input type="hidden" name="token" value="{TOKEN}">
263 </form>
264 <script type="text/javascript">
265 document.getElementById("auth").submit();
266 </script>
267 </html>""".format(PORT=self.port, PAGE_NAME=tool_name, TOKEN=self.access_token)
268 # use a local html file to send access token to our service via http POST for authentication.
269 os.makedirs(localdata_dir, exist_ok=True)
270 filename = os.path.join(localdata_dir, "launch_{}.html".format(tool_name))
271 with open(filename, "w") as f:
272 f.write(user_html)
273 os.startfile(filename)
274
275 def run(self, tool_name):
276 # find a port number that's available

Callers 1

runMethod · 0.95

Calls 3

joinMethod · 0.80
formatMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected