简体   繁体   中英

GAE Python Server initiating Angular Routes from Responses

I'm currently building a web application using AngularJS, Webapp2, and the Python Google App Engine environment. This app is supposed to have all the features of modern social networks (users, posts, likes, comments). I want the page hierarchy to look like this, the main pages are from the server and the sub pages are supposed to be angular routes:

Index

  • Learn More
  • Sign up
  • Log in

Feed Page

  • Popular Feed
  • Following Feed

Profile

  • Interactions
  • Posts

Settings

  • Profile
  • Account

The problem is that when a user wants to signup I want them to be able to go to /signup and get the index page with the signup route loaded. How can I get the server to preload an angular route from the response

I'm working on the same stack and the way we do it is that we have the main pages (index, login, signup) configured as regular individual pages where we use angular without routing. Any page that anonymous users will access will be such pages which work over server side routing. But once the user login is successful we serve a page which will start serving other views through client side routing.

Make both GAE and Angular understand your routes. You will need to define them for one, why not both?

You just have to organise your markup and structure so it can support complete page loading and ajax loading. For example, initial load is done on any route by GAE, then Angular can take over, loading each page "content" as it goes.

This has the additional advantage of public pages being crawler friendly while real users get ajax loading (which should reduce bandwidth once you scale).

You may need to load user state in via the server, and or force a page reload on log in or out to do so.

I have done the above on a few apps, and it works well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM