ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have tried a python code that creates simulation or graphic. The code runs fine in the executable mode .py. Now, I want to show it in a web page using cgi. I tried the following
==========================
#!/usr/bin/python
print "Content-Type:application/octet-stream\n\n"
# python code here that create simulation or graphic
====================================
When I try using the web browser, the page only show a message
visual-2003-10-25
There is no simulation or graphic. I will be happy if there are any suggestion about this problem. Is it poblem in the header or something else ?
Here's some probing questions (and my assumptions):
Which web server do you use? [Apache]
How is python made available? [mod_python]
Is there a problem in showing us the code? [no]
Is there a problem in showing us a minimal script that generates the same kind of output? [no]
Is there a problem in showing us the full code output(*)? [no]
Which browsers have you tested the script in? [firefox only]
Quote:
Is it poblem in the header or something else?
This is kinda' like asking why your square block won't fit into your hole without saying whether the hole is square, round or triangular. What kind of data does the code produce?
if (ball.y <= 0):
#print "Landed at (%f, %f, %f)" % (ball.pos.x, ball.pos.y, ball.pos.z)
info1=label(pos=(-300,-400,-100))
info1.text="Landed at (%f, %f, %f)" % (ball.pos.x, ball.pos.y, ball.pos.z)
break # Stop this loop so the program can exit
========================================================
you can try the code. I want to show the simulation in a web. Is it possible ?
A friend suggested to change the DefaultType at httpd.conf from text/plain to application/octet-stream. Unfortunately, it still doesn't wotk.
Could you please post the code again, this time using *code* tags around the code?
As a rule of thumb: if you expect anything to be in a fixed-width font when you read it, put it in code tags. Python scripts, shell commands (save for the really short single lines), C, config or log files, ...
Did I guess correctly regarding Apache (looks like it, but one can never know), mod_python and firefox?
I tried to tag, but submit reply button returns them to the first column.
I will use <tag> to indicate that it is being "tag" and <tag><tag> indicates 2 "tag". I use apache 2. For web browesr,
I use mozilla
===================================
#!/usr/bin/python
<tag> if (ball.y <= 0):
<tag><tag> #print "Landed at (%f, %f, %f)" % (ball.pos.x, ball.pos.y, ball.pos.z)
<tag> <tag> info1=label(pos=(-300,-400,-100))
<tag> <tag> info1.text="Landed at (%f, %f, %f)" % (ball.pos.x, ball.pos.y, ball.pos.z)
<tag> <tag> break # Stop this loop so the program can exit
=======================================
you should have visual module installed
What jonas means is to put [ code ] before your program and [ /code ] after it. Here I've also put spaces between the brackets and the word code, to make them appear. Just remove them and it will work.
Also, I tried to run your code, but I think I don't have the module "visual".
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.