473,325 Members | 2,872 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,325 software developers and data experts.

=?UTF-8?B?ZHluYW1pY2FsbHkgY3JlYXRpbmcgaHRtbCBjb2RlIHdpdG ggcHl0aG9uLi4u?=

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 not work. Below is the code that does not work.

Expand|Select|Wrap|Line Numbers
  1. f=StringIO.StringIO()
  2. f.write('<html><head><title>data analysis</title></head><body>')
  3. f.write(urllib.urlopen("http://localhost/path2Libs/myLibs.py", urllib.urlencode(TheData)))
  4. f.write("</body></html>")
  5.  
  6. print "Content-type: text/html\n"
  7. print f.read()
  8. f.close()
  9.  
What is wrong with this approach/code? Is there an easier way of doing it?

Thanks.

Aug 11 '08 #1
2 1006
an****@anartz.cjb.net wrote:
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 not work. Below is the code that does not work.
Help us help you. "Does not work" is not a helpful description. Do you
get an error message? If so, what is the error message? Do you get an
unexpected result? If so, what is the unexpected result, and what is the
result you expected?
Is there an easier way of doing it?
Probably. You seem to be invoking a python program that's local to your
computer, so it's not quite clear why you're going the roundabout way of
serving it up through a web server. Then again, you're not telling us
the actual problem you're trying to solve, so we have no idea what the
best solution to that problem might be.

--
Carsten Haese
http://informixdb.sourceforge.net
Aug 11 '08 #2
Hi,

an****@anartz.cjb.net wrote:
how can I combine some dynamically generated html code (using python) with
the output of a urllib.openurl() call?
Why reinvent the wheel? Try one of the existing web frameworks. There may be a
learning curve for most of them, but you may also end up doing things that
seem totally out of reach with your current approach.

http://wiki.python.org/moin/WebFrameworks

or, more generally:

http://wiki.python.org/moin/WebProgramming

Stefan
Aug 12 '08 #3

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

Similar topics

9
by: lawrence | last post by:
Someone on www.php.net suggested using a seems_utf8() method to test text for UTF-8 character encoding but didn't specify how to write such a method. Can anyone suggest a test that might work?...
4
by: Alban Hertroys | last post by:
Another python/psycopg question, for which the solution is probably quite simple; I just don't know where to look. I have a query that inserts data originating from an utf-8 encoded XML file....
12
by: Mike Dee | last post by:
A very very basic UTF-8 question that's driving me nuts: If I have this in the beginning of my Python script in Linux: #!/usr/bin/env python # -*- coding: UTF-8 -*- should I - or should I...
38
by: Haines Brown | last post by:
I'm having trouble finding the character entity for the French abbreviation for "number" (capital N followed by a small supercript o, period). My references are not listing it. Where would I...
6
by: jmgonet | last post by:
Hello everybody, I'm having troubles loading a Xml string encoded in UTF-8. If I try this code: ------------------------------ XmlDocument doc=new XmlDocument(); String s="<?xml...
6
by: archana | last post by:
Hi all, can someone tell me difference between unicode and utf 8 or utf 18 and which one is supporting more character set. whic i should use to support character ucs-2. I want to use ucs-2...
7
by: Jimmy Shaw | last post by:
Hi everybody, Is there any SIMPLE way to convert from UTF-16 to UTF-32? I may be mixed up, but is it possible that all UTF-16 "code points" that are 16 bits long appear just the same in UTF-32,...
1
by: sheldon.regular | last post by:
I am new to unicode so please bear with my stupidity. I am doing the following in a Python IDE called Wing with Python 23. äöü äöü '\xc3\xa4\xc3\xb6\xc3\xbc' u'\xe4\xf6\xfc'...
10
by: Jed | last post by:
I have a form that needs to handle international characters withing the UTF-8 character set. I have tried all the recommended strategies for getting utf-8 characters from form input to email...
23
by: Allan Ebdrup | last post by:
I hava an ajax web application where i hvae problems with UTF-8 encoding oc chineese chars. My Ajax webapplication runs in a HTML page that is UTF-8 Encoded. I copy and paste some chineese chars...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.