Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; '*not*': 0.07; 'subject:file': 0.07; "'''": 0.09; 'idea?': 0.09; 'template': 0.11; '.py': 0.16; 'did,': 0.16; 'f.read()': 0.16; 'from:addr:r.koebler': 0.16; 'from:name:roland koebler': 0.16; 'received:78.47': 0.16; 'wrote:': 0.17; 'skip:" 30': 0.20; 'skip:= 10': 0.20; 'this:': 0.23; 'tried': 0.25; 'header:In-Reply-To:1': 0.25; 'skip:" 20': 0.26; 'embed': 0.29; 'subject:end': 0.29; 'subject:some': 0.29; '(and': 0.32; 'print': 0.32; 'subject: .': 0.33; 'subject:data': 0.33; 'to:addr:python-list': 0.33; 'hi,': 0.33; 'skip:d 20': 0.34; 'wrong': 0.34; 'open': 0.35; 'doing': 0.35; 'but': 0.36; 'correctly': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'subject:-': 0.40; 'end': 0.40; 'content-disposition:inline': 0.60; 'said:': 0.65; '8bit%:100': 0.70; '2013': 0.84; 'url:show': 0.84 Date: Wed, 6 Mar 2013 10:00:14 +0100 From: Roland Koebler To: python-list@python.org Subject: Re: Inserting-embedding some html data at the end of a .py file References: <7e0a8562-9a48-4f5a-804d-3751733288f0@googlegroups.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1362560416 news.xs4all.nl 6841 [2001:888:2000:d::a6]:52212 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:40614 Hi, On Tue, Mar 05, 2013 at 09:39:19AM -0800, Νίκος Γκρ33κ wrote: > But i did, I just tried this: > > # open html template > if htmlpage.endswith('.html'): > f = open( "/home/nikos/public_html/" + htmlpage ) > > htmldata = f.read() > counter = '''
>
> > > ''' % data[0] > else: > f = open( "/home/nikos/public_html/cgi-bin/" + htmlpage ) > > htmldata = f.read() > counter = ''' > print '''
>
Αριθμός Επισκεπτών %d
> > > ''' > ''' % data[0] > > template = htmldata + counter > print ( template ) > ============= > > But still doens't embed correctly the additional html data at the end of the .py files..... > > Do you have an idea? as someone said: You're doing it the wrong way. I would recommend to use a template-engine; then you can put the complete html-design (and some design-control-structures) into the template (and *not* into the cgi) and fill data into the template with a python-script. Roland
Αριθμός Επισκεπτών %d