Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 7th, 2004, 03:04 PM
caroundw5h caroundw5h is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Canada
Posts: 181 caroundw5h User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 55 m 53 sec
Reputation Power: 0
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."


Reply With Quote
  #2  
Old May 8th, 2004, 01:54 AM
sadrok sadrok is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Location: South Africa
Posts: 9 sadrok User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #3  
Old May 8th, 2004, 08:00 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,536 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 3 m 4 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
  #4  
Old May 8th, 2004, 08:52 AM
sfb sfb is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 447 sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 1 h 43 m 45 sec
Reputation Power: 9
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

Reply With Quote
  #5  
Old May 8th, 2004, 02:17 PM
caroundw5h caroundw5h is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Canada
Posts: 181 caroundw5h User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 55 m 53 sec
Reputation Power: 0
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.

Reply With Quote
  #6  
Old May 8th, 2004, 02:55 PM
sfb sfb is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 447 sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 1 h 43 m 45 sec
Reputation Power: 9
Quote:
i don't want to use it as a cgi script. i have all of that figured out already.

Ok...

Quote:
what i want to do is have a python executable

As in, python script with executable permissions, or an .EXE file?

Quote:
on my site that will executate like an execuatable. my server is supposed to interpret it and do it

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:
so the user doesn't need to have python installed.

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?

Reply With Quote
  #7  
Old May 9th, 2004, 10:13 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,536 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 3 m 4 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.

Reply With Quote
  #8  
Old May 9th, 2004, 10:59 PM
caroundw5h caroundw5h is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Canada
Posts: 181 caroundw5h User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 55 m 53 sec
Reputation Power: 0
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.

Reply With Quote
  #9  
Old May 10th, 2004, 08:51 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,536 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 3 m 4 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.

Reply With Quote
  #10  
Old May 10th, 2004, 01:00 PM
penngray penngray is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 38 penngray User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 31 sec
Reputation Power: 6
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.

Reply With Quote
  #11  
Old May 11th, 2004, 02:19 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,536 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 3 m 4 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > python.exe on the web


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |