How to Write Python Script in html
There are more than just security problems. It's just not possible. You can't use the Python socket library inside the client browser. You can convert Python code to JS (probably badly) but you can't use a C based library that is probably not present on the client. You can access the browser only. You cannot reliably get the hostname of the client PC. Maybe ask another question talking about what you are trying to achieve and someone might be able to help
I want to execute my python code on the side even though there might be security problem 
How can I write with importing modules and all?
    I have tried using of pyjs to convert the below code to JS
import socket
print socket.gethostbyname_ex(socket.gethostname())[2][0]
but I am not find how to do the same.
Please help me how to how can convert this to JS and how to write other the python scripts and how to  import modules in HTML.