473,387 Members | 1,455 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 1403

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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.