# Python question

**URL:** <https://forums.suse.com/t/python-question/23005>\
**Category:** Chatting over the Back Fence\
**Created:** [August 23, 2012, 12:35am UTC](https://forums.suse.com/t/python-question/23005 "2012-08-23T00:35:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![System1](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@System1](https://forums.suse.com/u/System1)\
**Post date:** [August 23, 2012, 12:35am UTC](https://forums.suse.com/t/python-question/23005/1 "2012-08-23T00:35:39Z")

</div>

I have a python script running under mod\_python/Apache2 that performs some  
searching on a small database. That part works brilliantly. It displays the  
data just fine but I am trying to display the results in a slightly less  
rudimentary form than what python dumps out by default. Ideally I would like  
a link or button to start a new query. Problem is I can’t seem to find a way  
to have python generate a response page with embedded html or links. Anyone  
have a link to a good resource for that?

Thanks.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex022/uploads/suse/original/2X/5/5012ba89e3ffb5220dac47d5ea0ba032e2fe1cb6.png) [@system](https://forums.suse.com/u/system)\
**Post date:** [August 23, 2012, 3:08pm UTC](https://forums.suse.com/t/python-question/23005/2 "2012-08-23T15:08:56Z")

</div>

On 22/08/2012 22:35, GofBorg wrote:[color=blue]

> I have a python script running under mod\_python/Apache2 that performs some  
> searching on a small database. That part works brilliantly. It displays the  
> data just fine but I am trying to display the results in a slightly less  
> rudimentary form than what python dumps out by default. Ideally I would like  
> a link or button to start a new query. Problem is I can’t seem to find a way  
> to have python generate a response page with embedded html or links. Anyone  
> have a link to a good resource for that?[/color]

Normally, you are expected to supply the HTML yourself, in the body -  
apache expects to get back a preformatted html page, and if it gets  
plain text then ok, it can handle that, but its not what it wants or is  
expecting.

I would expect therefore you to use print lines to send something like:

Page Title
# Page Heading

… python code goes here, until you get to an output loop, then per-row:

\<Data column 2

… then exit the loop and do:

| Column one header | Column two header |
| --- | --- |
| Data column 1 |

* * *
Argument one:   
Argument two:   

that should give you a nicely formatted table, and a submission form.  
you can prepopulate the value fields to give the last submitted input if  
you want too.

obviously a real-world page will usually be more complex than that, but  
given I don’t know your site, its hard to say what extra ornamentation  
you need 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex022/uploads/suse/original/2X/5/5012ba89e3ffb5220dac47d5ea0ba032e2fe1cb6.png) [@system](https://forums.suse.com/u/system)\
**Post date:** [August 24, 2012, 12:01am UTC](https://forums.suse.com/t/python-question/23005/3 "2012-08-24T00:01:35Z")

</div>

Thanks Dave,

That was what I was trying to do but didn’t understand how to  
‘print’ the html codes. Makes sense now.
