btw, credits for the code shown below also for:
Anartz@anartz.c jb.net wrote :
Anartz@anartz.c jb.net wrote :
This makes sense. Thanks!
>
I managed to get what I wanted with something similar to what you suggested:
>
>
and the script returns
>
>
This works fine in Firefox, but not in IE7. Any ideas why?
>
BTW, you are right about me not having a clue about http. It's the first time I try to do something with it. May be you could point me out to some good links where I can learn.
>
I will take a look into Mako too.
>
Thanks again.
>
Bruno Desthuilliers <bdesth.quelque chose@free.quel quepart.frwrote :
>
>
>
>
--
http://mail.python.org/mailman/listinfo/python-list
>
I managed to get what I wanted with something similar to what you suggested:
>
Code:
print "Content-Type: text/html\n\n" html=""" <html> <head> <title> data analysis site </title> </head> <body> <p>This is a test</p> <IMG SRC="%s" /> <p>After image text</p> </body> </html>""" > print html % myChartsLib.myPlotType(TheData)
and the script returns
>
Code:
f = StringIO.StringIO() pylab.savefig(f) return 'data:image/png,' + urllib.quote(f.getvalue())
This works fine in Firefox, but not in IE7. Any ideas why?
>
BTW, you are right about me not having a clue about http. It's the first time I try to do something with it. May be you could point me out to some good links where I can learn.
>
I will take a look into Mako too.
>
Thanks again.
>
Bruno Desthuilliers <bdesth.quelque chose@free.quel quepart.frwrote :
>
anartz@anartz.c jb.net a écrit :
Indeed. Using an http request to call a local script is totally
braindead, but this is another problem.
Which one ? What you showed is a way to generate an image resource (with
mime-type 'image/png'), not an html page resource (mime-type :
text/html). Images resources are not directly embedded in html pages -
they are *referenced* from web pages (using an <imgtag), then it's up
to the user-agent (usually, the browser) to emit another http request to
get the image.
Not tested (obviously), but what you want is something like:
print "Content-type: text/html\n"
print """
<html>
<head>
<title>data analysis site</title>
</head>
<body>
<p>This is a trial test</p>
<img src="http://localhost/myLibs/ChartLib.py?%s" />
</body>
</html>
""" % urllib.urlencod e(TheData)
The code you showed so far either tried to add text/html to an image
(that is, binary data), or to embed the image's binary data into
text/html. None of this makes sense. Period. The problem is not with
Python. The problem is that you can't seriously hope to do web
programming without any knowledge of the http protocol.
Also and FWIW, you'd be better using a decent templating system (mako,
cheetah, genshi, tal, whatever fits your brain) instead of generating
html that way.
--
http://mail.python.org/mailman/listinfo/python-list
Sorry, my fault...
>
I am trying to build a web application for data analysis. Basically
some data will be read from a database and passed to a python script
(myLibs.py) to build an image as follows.
>
>
This section behaves as expected, and I can see the chart on the
web-page.
>
I am trying to build a web application for data analysis. Basically
some data will be read from a database and passed to a python script
(myLibs.py) to build an image as follows.
>
Code:
f=urllib.urlopen("http://localhost/path2Libs/myLibs.py",urllib.urlencode(TheData)) print "Content-type: image/png\n" print f.read() f.close()
This section behaves as expected, and I can see the chart on the
web-page.
braindead, but this is another problem.
Now, I would like to add some text and possibly more charts
(generated in the same way) to my web-page.
(generated in the same way) to my web-page.
mime-type 'image/png'), not an html page resource (mime-type :
text/html). Images resources are not directly embedded in html pages -
they are *referenced* from web pages (using an <imgtag), then it's up
to the user-agent (usually, the browser) to emit another http request to
get the image.
This is what I need help
with.
with.
print "Content-type: text/html\n"
print """
<html>
<head>
<title>data analysis site</title>
</head>
<body>
<p>This is a trial test</p>
<img src="http://localhost/myLibs/ChartLib.py?%s" />
</body>
</html>
""" % urllib.urlencod e(TheData)
My question: How can I use python to dynamically add descriptive
comments (text), and possibly more charts to the web-page?
comments (text), and possibly more charts to the web-page?
(that is, binary data), or to embed the image's binary data into
text/html. None of this makes sense. Period. The problem is not with
Python. The problem is that you can't seriously hope to do web
programming without any knowledge of the http protocol.
Also and FWIW, you'd be better using a decent templating system (mako,
cheetah, genshi, tal, whatever fits your brain) instead of generating
html that way.
--
http://mail.python.org/mailman/listinfo/python-list
>
>
--
http://mail.python.org/mailman/listinfo/python-list