Re: Inserting-embedding some html data at the end of a .py file

Discussion in 'Python' started by Íßêïò Ãêñ33ê, Mar 5, 2013.

  1. #open html template
    if htmlpage.endswith('.html'):
    f = open( "/home/nikos/public_html/" + htmlpage )

    htmldata = f.read()
    counter = ''' <center><a href="mailto:"> <img src="/data/images/mail.png"> </a>
    <center><table border=2 cellpadding=2 bgcolor=black>
    <td><font color=lime>Áñéèìüò Åðéóêåðôþí</td>
    <td><a href="http://superhost.gr/?show=stats"><font color=cyan> %d </td>
    ''' % data[0]

    #render template
    template = htmldata + counter
    print ( template )
    ============================================
    Yes the aboev code does work if we talk about appending html data to an already html file!

    But if the file is some_python.py file then i cannot just append the data.
    Actually by appending i dont want to actually insert the data to the end ofthe .py file, thus altering it but instead run the .py file and print the counter html data afterwards!
    Íßêïò Ãêñ33ê, Mar 5, 2013
    #1
    1. Advertising

  2. Íßêïò Ãêñ33ê

    Dave Angel Guest

    On 03/05/2013 03:04 PM, Íßêïò Ãêñ33ê wrote:
    > #open html template
    > if htmlpage.endswith('.html'):
    > f = open( "/home/nikos/public_html/" + htmlpage )
    >
    > htmldata = f.read()
    > counter = ''' <center><a href="mailto:"> <img src="/data/images/mail.png"> </a>
    > <center><table border=2 cellpadding=2 bgcolor=black>
    > <td><font color=lime>Áñéèìüò Åðéóêåðôþí</td>
    > <td><a href="http://superhost.gr/?show=stats"><font color=cyan> %d </td>
    > ''' % data[0]
    >
    > #render template
    > template = htmldata + counter
    > print ( template )
    > ============================================
    > Yes the aboev code does work if we talk about appending html data to an already html file!
    >
    > But if the file is some_python.py file then i cannot just append the data.
    > Actually by appending i dont want to actually insert the data to the end of the .py file, thus altering it but instead run the .py file and print the counter html data afterwards!
    >


    In other words, you're just trying to waste our time. Thanks for
    telling us.

    --
    DaveA
    Dave Angel, Mar 5, 2013
    #2
    1. Advertising

  3. Íßêïò Ãêñ33ê

    Michael Ross Guest

    On Tue, 05 Mar 2013 21:04:59 +0100, Îίκος ΓκÏ33κ <>
    wrote:

    > #open html template
    > if htmlpage.endswith('.html'):
    > f = open( "/home/nikos/public_html/" + htmlpage )
    >
    > htmldata = f.read()
    > counter = ''' <center><a href="mailto:"> <img
    > src="/data/images/mail.png"> </a>
    > <center><table border=2 cellpadding=2 bgcolor=black>
    > <td><font color=lime>ΑÏιθμός Επισκεπτών</td>
    > <td><a href="http://superhost.gr/?show=stats"><font color=cyan>
    > %d </td>
    > ''' % data[0]
    >
    > #render template
    > template = htmldata + counter
    > print ( template )
    > ============================================
    > Yes the aboev code does work if we talk about appending html data to an
    > already html file!
    >
    > But if the file is some_python.py file then i cannot just append the
    > data.
    > Actually by appending i dont want to actually insert the data to the end
    > of the .py file, thus altering it but instead run the .py file and print
    > the counter html data afterwards!



    subprocess.checkoutput() ?

    if htmlpage.endswith('.py'):
    htmldata=subprocess.check_output(...)
    counter=...
    template=htmldata+counter

    http://docs.python.org/2/library/subprocess.html?highlight=check_output#subprocess.check_output
    Michael Ross, Mar 5, 2013
    #3
  4. Ôç Ôñßôç, 5 Ìáñôßïõ 2013 11:02:18 ì.ì. UTC+2, ï ÷ñÞóôçò Dave Angel Ýãñáøå:

    > In other words, you're just trying to waste our time. Thanks for
    >
    > telling us.


    Honestly, its not in my intentions to waste your time.
    I appreciate all the great help you have provided me in all of my questions, i really do.

    I'am sorry if i sometimes cannot express myself correctly in english, hencei cannot descrive exactly what i want to accomplish.

    I'am sorry about that but english its not my native language.
    Íßêïò Ãêñ33ê, Mar 5, 2013
    #4
  5. Ôç Ôñßôç, 5 Ìáñôßïõ 2013 11:02:18 ì.ì. UTC+2, ï ÷ñÞóôçò Dave Angel Ýãñáøå:

    > In other words, you're just trying to waste our time. Thanks for
    >
    > telling us.


    Honestly, its not in my intentions to waste your time.
    I appreciate all the great help you have provided me in all of my questions, i really do.

    I'am sorry if i sometimes cannot express myself correctly in english, hencei cannot descrive exactly what i want to accomplish.

    I'am sorry about that but english its not my native language.
    Íßêïò Ãêñ33ê, Mar 5, 2013
    #5
    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. Jimmy
    Replies:
    3
    Views:
    313
    J. J. Farrell
    Sep 9, 2011
  2. Renie83
    Replies:
    1
    Views:
    169
    Kiran Math
    Jul 10, 2003
  3. Íßêïò Ãêñ33ê
    Replies:
    2
    Views:
    136
    Joel Goldstick
    Mar 5, 2013
  4. Íßêïò Ãêñ33ê
    Replies:
    9
    Views:
    134
    Roland Koebler
    Mar 6, 2013
  5. Íßêïò Ãêñ33ê
    Replies:
    34
    Views:
    469
    Chris Angelico
    Mar 7, 2013
Loading...

Share This Page