|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
python.exe on the web
on my web site I want to make a link to a python program that when the user clicks it it will execute a python program. I saw this somewhere before, but i'm not sure how it was done. i tried to simple set a href = prog.py, and i've configured my web server to accept that extension, but i keep getting an internal 500 error.
Any ideas how to do this.
__________________
"In theory, there is no difference between theory and practice. But, in practice, there is."
|
|
#2
|
|||
|
|||
|
It is possible that the prog.py script doesn't produce the correct headers.
It should at least output a Content-Type line: print "Content-Type: text/html" print # note a new line is needed before any content is sent This line should be the first line printed/outputted by your program. Another reason could be the script is causing an error/exception (I get this alot). If you have access to error-logs you might be able to see what is going on. Good luck |
|
#3
|
||||
|
||||
|
If the page runs normally though the server then you shouldn't have any problem linking to it. That is assuming its a CGI program which as Sad said has a few requirements.
Is your Python program in the the same dir as your html, if not then you should check the path. It may be worth bringing up that it must be in a place visable by the web server. But i dont think this is your problem since your getting a 500 error ![]() Mark. |
|
#4
|
|||
|
|||
|
If you're using CGI - and it sounds like you are, the things you need to do are;
Code:
import cgi import cgitb cgitb.enable() # Change the content-type as appropriate print "Content-type: text/plain\n\n" # code goes here print "Hello from my cgi script" Now click the link again, and with cgi-traceback (cgitb) enabled, you should get a Python traceback as well as the error message, so you can see what went wrong. Great for development, but remember to turn it off before you finish, it's not a very pretty sight for users ![]() |
|
#5
|
|||
|
|||
|
i don't want to use it as a cgi script. i have all of that figured out already. what i want to do is have a python executable on my site that will executate like an execuatable. my server is supposed to interpret it and do it, so the user doesn't need to have python installed.
|
|
#6
|
||||||
|
||||||
|
Quote:
Ok... Quote:
As in, python script with executable permissions, or an .EXE file? Quote:
ok, if the server interprets it, then it must be a script not an EXE. So the server runs the Python when the user clicks on a hyperlink? Quote:
If the server is interpreting it, the user doesn't need Python installed, check. What you are describing is a cgi script. It doesn't have to produce any output to the user. It is far and away the easiest way to trigger the server processing something at the click of a link. Why don't you want to use it? |
|
#7
|
||||
|
||||
|
Like Sfb said any server-side process requires nothing from the users end except that he or she exists and what your describing sounds like CGI to me, unless you have client-side and server-side mixed up.
In which case you want an executable (say from py2exe or similar - which would the server to run on windows... if you use p2exe) to run on your server without Python being installed? Mark. |
|
#8
|
|||
|
|||
|
i guess the question is like this: suppose i create a tic tac toe game in python. and i want to put it on my website so others can play the game. it is not a cgi script. as if they had it on their computer. since i'm using python already for cgi scripting can't the program excute and have the user play the game. i just want to use python to create dynamic webpages. like javascript, and i'm thinking the user does not need to have it installed since my server has it installed already. is this not possible. or is this something where the browser HAS to support python.
thank you all for your time in answering. |
|
#9
|
||||
|
||||
|
Now i'm hearing the applet, i might be wrong but when you talk about games i imagin GUI - in which case this is only possable with Grail (a browser writen in Python which is no longer being activly developed) or using Jython...
If you want to use Python like Javascript then yes this is possable but you need to have Python installed on the clients computer. And i believe you also need the win32all module to do this on windows. Yet to hear of anything like this on *nix though Mark. |
|
#10
|
|||
|
|||
|
Maybe you should consider using mod-python?? No need to have python running on the client side.
Then you can access all your python code from a webpage using forms, links, etc. |
|
#11
|
||||
|
||||
|
mod_python just provides another way to handle Python on the web although it does still provides a CGI handler if you're not comfortable with the default publisher handler.
I guess we've got a little comfused about what we want to do here but CGI or mod_python should t the job in most cases. The problem arises when you have to have an interactive GUI (an applet) or want to effect the browser in a similar way which Javascript does (in which case we're talking Client-Side). Still waiting for PSP to become stable and supported - thats gonna be great! Mark. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > python.exe on the web |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|