On Thursday, March 15, 2018 at 8:01:48 AM UTC-4, Ur. Kr. wrote:
>
> I'm currently using React/ReactRouter/Redux. The main issue is for web2py
> to serve the same view wherefrom the javascript determines what other
> requests to make and what to render.
> Now if I have
> controller file controllers/default.py
> Then I go to default/page
> This doesn't work if there's no `page` function in default.py and if there
> isn't a page.html file the views folder.
> For the SPA I need it to just serve a single HTML file regardless of the
> url components after "default/".
> I suppose I could use the # fragment: default#/page
>
It sounds like it's not that you want to use the same *view *with each
request but rather the same controller action. In other words, all of the
different URLs of your app are really client-side URLs, so no matter what
URL is requested, you want web2py to call the same controller action and
simply return the SPA. To do that, in a model file, you can add something
like this:
if request.controller == 'default':
request.function = 'index'
response.view = 'default/index.html'
Assuming the client-side routes are all at the /default URL path (which
presumably you will hide using the web2py router), the above will re-route
any request for the /default path to the index() function, which you should
set up to return the SPA. You could also use the pattern-based rewrite
system to do something similar.
Any other web2py server-side routes should go in other controllers (e.g.,
Auth endpoints) to make it easy to distinguish client-side vs. server-side
routes.
Anthony
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.