I have written a python console based program. It takes few arguments (like file name ) for execution. I want to run it from the browser... How can I parse this arguments and execute that python code Any clues..approaches. Thanks
-
1Execute Python just like Javascript in a browser? If that's what you mean, that's not possible... But there is an interesting Python to Javascript compiler.John Doe– John Doe2011-12-01 18:03:06 +00:00Commented Dec 1, 2011 at 18:03
-
@JohnDoe: I am trying that out.. but I am facing a weird problem.. Its example scripts run just fine.. but then if i use its library in a program... then the is some python-hulahop which it says is missing and I am not able to find it anywhere for ubuntu.. :(frazman– frazman2011-12-01 18:08:56 +00:00Commented Dec 1, 2011 at 18:08
-
How about Skulpt? Although, Pyjamas still looks like the best bet...John Doe– John Doe2011-12-01 18:15:20 +00:00Commented Dec 1, 2011 at 18:15
-
And if what you meant was more like a server side Python application, I use Django for that. But client side Python scripting isn't really feasible. :)John Doe– John Doe2011-12-01 18:23:03 +00:00Commented Dec 1, 2011 at 18:23
Add a comment
|
1 Answer
Maybe you should clarify your problem. At least i don't fully understand why you want to run a terminal program in the browser?
But if you want to reuse some code you have already written you could use a micro framework like Flask.
Check this example from flask's docs:
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run()
So you could write a simple view that accepts the arguments you need and the view would then call your code and return whatever you want, most likely an http response.