Re: Passing variables to view
Germán Rimoldi <[email protected]> Sat, 24 Dec 2016 10:57:27 -0800 (PST)
| Newsgroups | gmane.comp.python.cherrypy |
|---|---|
| Message-ID | <[email protected]> |
Much appreciated Raph!
It works like a charm
:)
On Sunday, December 18, 2016 at 6:39:40 PM UTC-3, Germán Rimoldi wrote:
>
> Hi Guys!
>
> I'm getting started with CherryPy. I'm finding the learning curve pretty
> steep for a newbie :(
>
> I have a very simple question: How do I pass variables to an html view?
>
> class Root:
> @cherrypy.expose
> def index(self):
> c = cherrypy.thread_data.db.cursor()
> c.execute('select count(*) from Website')
> res = c.fetchone()
> c.close()
> open("index.html")
> cherrypy.quickstart(Root())
>
> My index.html, being:
> <html>
> <head></head>
> <body>
> Hello, you have %d records in your table %res[0]
> </body>
> </html>
>
> How should I rewrite my index function, to render the variables to my html
> file?
>
--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.