473,473 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Re: dynamically creating html code with python...

On Mon, Aug 11, 2008 at 10:05 AM, <an****@anartz.cjb.netwrote:
Hi,

Thanks for your patience.

I got the text displayed in the web browser with the following code:

Expand|Select|Wrap|Line Numbers
  1. f=StringIO.StringIO()
  2. f.write('<html><head><title>data analysis site</title></head><body>')
  3. f.write("<p>This is a trial test</p>")
  4. f.write("</body></html>")
  5. print "Content-type: text/html\n"
  6. print f.getvalue()
  7. f.close()
  8.  

Now I am trying to put both the image and the text together, but the following lines do not create the text with the chart that I expected.

Expand|Select|Wrap|Line Numbers
  1. f=StringIO.StringIO()
  2. f.write('<html><head><title>data analysis site</title></head><body>')
  3. f.write("<p>This is a trial test</p>")
  4. f.write(urllib.urlopen("http://localhost/myLibs/ChartLib.py",urllib.urlencode(TheData)))
  5. f.write("</body></html>")
  6. print "Content-type: text/html\n"
  7. print f.getvalue()
  8. f.close()
  9.  

I am wondering if urllib.urlopen is the command I need to revise.

Thanks for the pointers as well. I will look into them.


Jerry Hill <ma*********@gmail.comwrote :
>On Mon, Aug 11, 2008 at 12:26 PM, <an****@anartz.cjb.netwrote:
I have tried calling a script containing the code below from a web browser and it did not get the text.

You quoted my post that answered this question, but did not implement
either of the two solutions I suggested. I continue to suggest that
you either: f.seek(0) before you f.read(), or that you replace
f.read() with f.getvalue().

Also, you may want to read the docs on
StringIO - http://docs.python.org/lib/module-StringIO.html
File objects - http://docs.python.org/lib/bltin-file-objects.html

--
Jerry

It looks to me like you are opening the url, but never retrieving the
content of the url.

I think you may have better luck with urllib2 which has a read() method.

http://docs.python.org/lib/urllib2-examples.html

--
Stand Fast,
tjg. [Timothy Grant]
Aug 11 '08 #1
0 1407

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Gaurav Gargate | last post by:
Hi Group, I am creating a ASP.NET (C#) project. I am creating a datalist with some dynamically generated text boxes in the edit template. I have the datalist control on the form. The text box...
2
by: Chad | last post by:
I have a problem that I am desperate to understand. It involves dynamically adding controls to a Table control that is built as a result of performing a database query. I am not looking to...
2
by: Patrick | last post by:
I want to define a set of web-form templates in XML and render the equivalent web-form with ASP.NET, then process any input server controls on the form. Reading the XML file from Page_load is...
5
by: Mike Dee | last post by:
Is it possible to dynamically create a new form object (form1), then create a new form field object and add it form1, and then add form1 to the current document? I need to do all this in script...
2
by: | last post by:
Hi, how can I combine some dynamically generated html code (using python) with the output of a urllib.openurl() call? I have tried to use the StringIO() class with .write functions, but it did...
0
by: Jerry Hill | last post by:
On Mon, Aug 11, 2008 at 12:26 PM, <anartz@anartz.cjb.netwrote: You quoted my post that answered this question, but did not implement either of the two solutions I suggested. I continue to...
1
by: | last post by:
Hi, Thanks for your patience. I got the text displayed in the web browser with the following code: f=StringIO.StringIO() f.write('<html><head><title>data analysis...
1
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have...
7
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.