Server rendering react using cherrypy...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Server rendering react using cherrypy...

samslists@gmail.com
I have written a web app all in cherrypy and sqlalchemy on the backend.  

The front end is all react. (I use mako templates but basically just to create a single div, and call the react script).

The site has about 50 pages, but it's react that parses each of these urls and makes appropriate server calls for json which it then parses and displays.

I'd like to pre-render the pages on the server.  I've seen some tutorials and instructions for Python in general, but nothing specifically for cherrypy.

Is there any documentation on rendering react on the server using cherrypy?

Thanks

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Server rendering react using cherrypy...

Tim Roberts
On Jan 15, 2017, at 10:00 PM, Sam <[hidden email]> wrote:
>
> I have written a web app all in cherrypy and sqlalchemy on the backend.  
>
> The front end is all react. (I use mako templates but basically just to create a single div, and call the react script).

> I'd like to pre-render the pages on the server.  I've seen some tutorials and instructions for Python in general, but nothing specifically for cherrypy.

I'm a little confused by your description.  When I hear "front end" and "back end", I assume that web requests go into the front-end first, and the front-end internally makes requests to the back-end for data.

If that's the case, then your desire doesn't make much sense, because the react scripts will always see the request first.

If the requests go to CherryPy first, then you certainly have the opportunity to cache results into files and use them later, but you might consider whether using a reverse proxy as the first contact makes sense.

Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Server rendering react using cherrypy...

samslists@gmail.com
Hi Tim...

Sorry if I wasn't clear. Basically I want to use a package like this https://github.com/markfinger/python-react and am looking for a specific tutorial or how-to about using it with cherrypy.

I'm sure I can figure it out on my own, but if a how-to for cherrypy already exists, I'd like to read it, if only to save a few hours.

Does that explain what I'm asking better?

Thanks





On Sunday, January 15, 2017 at 11:23:21 PM UTC-8, Tim Roberts wrote:
On Jan 15, 2017, at 10:00 PM, Sam <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="rHKR_czxFgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">sams...@...> wrote:
>
> I have written a web app all in cherrypy and sqlalchemy on the backend.  
>
> The front end is all react. (I use mako templates but basically just to create a single div, and call the react script).

> I'd like to pre-render the pages on the server.  I've seen some tutorials and instructions for Python in general, but nothing specifically for cherrypy.

I'm a little confused by your description.  When I hear "front end" and "back end", I assume that web requests go into the front-end first, and the front-end internally makes requests to the back-end for data.

If that's the case, then your desire doesn't make much sense, because the react scripts will always see the request first.

If the requests go to CherryPy first, then you certainly have the opportunity to cache results into files and use them later, but you might consider whether using a reverse proxy as the first contact makes sense.

Tim Roberts, <a href="javascript:" target="_blank" gdf-obfuscated-mailto="rHKR_czxFgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">ti...@...
Providenza & Boekelheide, Inc.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Server rendering react using cherrypy...

matt Gerwen van
Hi Tim,

I also like to combine react 16.2 (native) with cherrypy. I'm not so good programmer, eventhough I like to learn and do some programming.  The examples of python-react are for Flask, not for Cherrypy. How did you go and did you solve this issue. Flask has it's own 'render-machine'. I like to hear from you, how you did go with it.

On Monday, January 16, 2017 at 10:14:27 AM UTC+1, Sam wrote:
Hi Tim...

Sorry if I wasn't clear. Basically I want to use a package like this <a href="https://github.com/markfinger/python-react" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmarkfinger%2Fpython-react\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH2m_5IrSHKC-s8j-cc75YEJc-txg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmarkfinger%2Fpython-react\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNH2m_5IrSHKC-s8j-cc75YEJc-txg&#39;;return true;">https://github.com/markfinger/python-react and am looking for a specific tutorial or how-to about using it with cherrypy.

I'm sure I can figure it out on my own, but if a how-to for cherrypy already exists, I'd like to read it, if only to save a few hours.

Does that explain what I'm asking better?

Thanks





On Sunday, January 15, 2017 at 11:23:21 PM UTC-8, Tim Roberts wrote:
On Jan 15, 2017, at 10:00 PM, Sam <[hidden email]> wrote:
>
> I have written a web app all in cherrypy and sqlalchemy on the backend.  
>
> The front end is all react. (I use mako templates but basically just to create a single div, and call the react script).

> I'd like to pre-render the pages on the server.  I've seen some tutorials and instructions for Python in general, but nothing specifically for cherrypy.

I'm a little confused by your description.  When I hear "front end" and "back end", I assume that web requests go into the front-end first, and the front-end internally makes requests to the back-end for data.

If that's the case, then your desire doesn't make much sense, because the react scripts will always see the request first.

If the requests go to CherryPy first, then you certainly have the opportunity to cache results into files and use them later, but you might consider whether using a reverse proxy as the first contact makes sense.

Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Server rendering react using cherrypy...

Tim Roberts
matt Gerwen van wrote:
> Hi Tim,
>
> I also like to combine react 16.2 (native) with cherrypy. I'm not so
> good programmer, eventhough I like to learn and do some programming. 
> The examples of python-react are for Flask, not for Cherrypy. How did
> you go and did you solve this issue. Flask has it's own
> 'render-machine'. I like to hear from you, how you did go with it.

It's always interesting when a thread from a year ago pops back to life.

I have never done it.  I've used CherryPy on its own, I've used CherryPy
with FastCGI behind Apache, and I've used React on its own.  Franky, I
don't see the point of combining them.  CherryPy already has the socket
processing needed to run a web server.  What is React going to buy you
in this case?

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Server rendering react using cherrypy...

matt Gerwen van
Hi Tim,

React is a very nice way to handle the front-end. What I gain from it, hmmm good question.
thanks for that inside. 

I do not understand what you mean by 'I've used react on its own'?
React version 0.15 can be used as a js-library within cherrypy, So far as I understand, React 16.2 needs npm to work. 
How did you use react and which version?


On Wednesday, February 28, 2018 at 12:46:26 AM UTC+1, Tim Roberts wrote:
matt Gerwen van wrote:
> Hi Tim,
>
> I also like to combine react 16.2 (native) with cherrypy. I'm not so
> good programmer, eventhough I like to learn and do some programming. 
> The examples of python-react are for Flask, not for Cherrypy. How did
> you go and did you solve this issue. Flask has it's own
> 'render-machine'. I like to hear from you, how you did go with it.

It's always interesting when a thread from a year ago pops back to life.

I have never done it.  I've used CherryPy on its own, I've used CherryPy
with FastCGI behind Apache, and I've used React on its own.  Franky, I
don't see the point of combining them.  CherryPy already has the socket
processing needed to run a web server.  What is React going to buy you
in this case?

--
Tim Roberts, <a href="javascript:" target="_blank" gdf-obfuscated-mailto="f5r6G9NdBAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">ti...@...
Providenza & Boekelheide, Inc.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Server rendering react using cherrypy...

Tim Roberts
matt Gerwen van wrote:
>
>
> I do not understand what you mean by 'I've used react on its own'?
> React version 0.15 can be used as a js-library within cherrypy, So far
> as I understand, React 16.2 needs npm to work. 
> How did you use react and which version?

Brain fart on my part, sorry.  When you said "React", my brain inserted
"Twisted Reactor".  I have never used React.

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Server rendering react using cherrypy...

matt Gerwen van
ooooh, oke, 

On Wednesday, February 28, 2018 at 6:15:35 PM UTC+1, Tim Roberts wrote:
matt Gerwen van wrote:
>
>
> I do not understand what you mean by 'I've used react on its own'?
> React version 0.15 can be used as a js-library within cherrypy, So far
> as I understand, React 16.2 needs npm to work. 
> How did you use react and which version?

Brain fart on my part, sorry.  When you said "React", my brain inserted
"Twisted Reactor".  I have never used React.

--
Tim Roberts, <a href="javascript:" target="_blank" gdf-obfuscated-mailto="egeZYxOXBAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">ti...@...
Providenza & Boekelheide, Inc.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Server rendering react using cherrypy...

Sviatoslav Sydorenko
You might want to look into https://github.com/amol-/dukpy as well

понеділок, 19 березня 2018 р. 09:00:35 UTC+1 користувач matt Gerwen van написав:
ooooh, oke, 

On Wednesday, February 28, 2018 at 6:15:35 PM UTC+1, Tim Roberts wrote:
matt Gerwen van wrote:
>
>
> I do not understand what you mean by 'I've used react on its own'?
> React version 0.15 can be used as a js-library within cherrypy, So far
> as I understand, React 16.2 needs npm to work. 
> How did you use react and which version?

Brain fart on my part, sorry.  When you said "React", my brain inserted
"Twisted Reactor".  I have never used React.

--
Tim Roberts, [hidden email]
Providenza & Boekelheide, Inc.

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.