0

I tried to link my HTML file with Python code.

I tried this

import webbrowser
webbrowser.open_new_tab("data.HTML")

It returned my HTML page in Firefox..

But i need to return to my Python program to execute remaining lines

But when I closed this browser, it closes my Python script too.

And I tried to link my Python program by,

<a href="c://user/elcot/pychat.py">go to Python</a>

it returns to text editor not to terminal...

But I need to return to terminal.

I need the solution

3
  • I would suggest you to use flask framework Commented Dec 21, 2017 at 4:29
  • What do you mean by "but i need to return to my Python program to execute remaining lines"? webbrowser.open_new_tab should not block until you close the browser. The rest of the script should continue executing. What do you mean by "connecting HTML with Python"? Please describe what you are trying to accomplish. Commented Dec 21, 2017 at 4:33
  • No bro...it didn't executing Commented Dec 21, 2017 at 4:34

1 Answer 1

1

As someone described, you need to use one web framework (like flask, django others) to run python code. Or the second solution is using CGI(http://modwsgi.readthedocs.io/en/develop/).

For the second problem(want to keep running python code after browser is closed), I want to advice to use Selenium.

Cheers, John

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.