I'm interested in having Python scripts in a web page. I'm planning simple scripts on the order of splitting strings and maybe a little bit more.
As in Javascript...
<html>
<script>
//stuff goes here
</script>
</html>
Except I want to use Python in the exact same way, or at least in a remotely similar way. Is there any way to accomplish this without a framework?
If I need a framework in the end, which one is best?
Thanks in advance!
No...Generally, you can't include a python script in <script></script>
tags.
Why not? Python isn't one of the scripting languages built into the visitors' browsers, like Javascript, or commonly installed as a plug-in like Java or Flash. There may very well be a Python plug-in somewhere, but it is not in common use. Asking someone to install a plug in, even Java or Flash, to view your site is considered a hassle and security risk by many.
The usual way to run python for web page generation is server-side, but you are not asking about that, so how could it run browser-side? The answer is the python interpreter must be written in an available browser language like Javascript or Java.
And surprise!, there is a Python interpreter written in Javascript (Skulpt)! Since this runs Python in Javascript, it does not require any plugin and would be visible to most visitors. You will need the skulpt code and probably can't use <script>
tags but could locate the python code in an visitor-editable <textarea>
input according to the skulpt instructions.
There is a more well-known variant of Python one written in Java (Jython applet example) but your visitors would need to have the Java browser plugin installed for it to be usable.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다