Re: in CGI, how to include html pages?

Discussion in 'Python' started by Nick Welch, Sep 6, 2003.

  1. Nick Welch

    Nick Welch Guest

    On Sat, Sep 06, 2003 at 11:05:44AM -0400, python wrote:
    > Hi-
    >
    > I'm writing some CGI stuff and I'm doing it in python to force myself to
    > learn the language. Anyway, I want to include some html at the top of
    > every page but I'm not sure how.
    >
    > If the header is in header.html, what is the python-ese way of printing
    > that out in my html?
    >
    > Thanks for the help.
    >
    > --
    > http://mail.python.org/mailman/listinfo/python-list


    f = file("header.html")

    for line in file:
    print line,

    f.close()

    And of course you could easily write a function to wrap this so you
    could just include("header.html").

    HTH,
    --
    Nick Welch aka mackstann | mack @ incise.org | http://incise.org
    If you have a procedure with 10 parameters, you probably missed some.
     
    Nick Welch, Sep 6, 2003
    #1
    1. Advertising

  2. Nick Welch

    Andrew Chalk Guest

    How about:

    htmlHeader = '''<html>

    <head>

    <meta http-equiv="Content-Language" content="en-us">

    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">

    <meta name="ProgId" content="FrontPage.Editor.Document">

    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">

    <title>New Process</title>

    </head>'''

    print htmlHeader


    "Nick Welch" <> wrote in message
    news:...
    > On Sat, Sep 06, 2003 at 11:05:44AM -0400, python wrote:
    > > Hi-
    > >
    > > I'm writing some CGI stuff and I'm doing it in python to force myself to
    > > learn the language. Anyway, I want to include some html at the top of
    > > every page but I'm not sure how.
    > >
    > > If the header is in header.html, what is the python-ese way of printing
    > > that out in my html?
    > >
    > > Thanks for the help.
    > >
    > > --
    > > http://mail.python.org/mailman/listinfo/python-list

    >
    > f = file("header.html")
    >
    > for line in file:
    > print line,
    >
    > f.close()
    >
    > And of course you could easily write a function to wrap this so you
    > could just include("header.html").
    >
    > HTH,
    > --
    > Nick Welch aka mackstann | mack @ incise.org | http://incise.org
    > If you have a procedure with 10 parameters, you probably missed some.
    >
     
    Andrew Chalk, Sep 6, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. python
    Replies:
    0
    Views:
    331
    python
    Sep 6, 2003
  2. Andreas Bogenberger
    Replies:
    3
    Views:
    960
    Andreas Bogenberger
    Feb 22, 2008
  3. Chris
    Replies:
    2
    Views:
    180
    Chris
    Sep 3, 2003
  4. Josef 'Jupp' Schugt

    (Ab)using class CGI as non-CGI HTML generator?

    Josef 'Jupp' Schugt, Mar 5, 2005, in forum: Ruby
    Replies:
    3
    Views:
    273
    Lee Braiden
    Mar 6, 2005
  5. me
    Replies:
    10
    Views:
    986
    ccc31807
    Mar 26, 2010
Loading...

Share This Page