Jason O.
Jason O.

Reputation: 3310

How to handle Polymer routing in Google Appengine

I'm trying to run this Polymer app (https://divshot.com/blog/web-components/building-a-qa-system-with-polymer-and-firebase/) on Google App Engine. I was able to get the first page to work by setting up the routing

webapp2.Route(r'/polymer', handler=project_handler.PolymerHandler, name='polymer'),

but when the Github oAuth successfully returns the login user back to the callback URL, the question input screen (list.html) doesn't show up. (FYI. When I run the exact same project outside of GAE, it works just fine. So I believe the issue is with my GAE routing setup.)

<core-header-panel>
  <div class="core-header">
    <core-toolbar>
      <div flex>Firebase Q&amp;A</div>
      <paper-menu-button halign="right">
        <paper-icon-button icon="social:person"></paper-icon-button>
        <paper-dropdown class="dropdown" transition="">
          <core-menu class="menu">
            <paper-item on-click="{{login}}" hidden?="{{!statusKnown || user}}">Login</paper-item>
            <paper-item on-click="{{logout}}" hidden?="{{!statusKnown || !user}}">Logout</paper-item>
          </core-menu>
        </paper-dropdown>
      </paper-menu-button>
      <template if="{{user}}">{{user.github.username}}</template>
    </core-toolbar>
  </div>
  <div class="content">
    <app-router>  <!-- This handles routing for Polymer app -->
      <app-route path="/" import="/app/component/questions/list.html" element="qa-list"></app-route>
      <app-route path="/app/component/questions/:id" import="/app/component/questions/view.html" element="qa-view"></app-route>
    </app-router>
  </div>
</core-header-panel>

Apparently this app-router isn't working.

Can you please point me to the right direction? Thanks.

Project structure

Project root
\app\
\app\index.html
\app\component
\app\component\qa.html
\app\component\questions\list.html
\bower_components
\app.yaml

App.yaml

handlers:

- url: /components
  static_dir: bower_components

- url: /app
  static_dir: app

- url: /
  static_files: app/index\.html
  upload: app/index\.html

Upvotes: 0

Views: 599

Answers (1)

Mihail Russu
Mihail Russu

Reputation: 2526

Since the project you are trying to run seems to entirely consist of static files there's no need to define the routes in webapp2 or use any python code at all as GAE could serve all that with some app.yaml settings which assuming that you have both bower_components and app folders in the root of your project in your case would be something like:

handlers:
- url: /bower_components
  static_dir: bower_components

- url: /app
  static_dir: app

- url: /
  static_files: app/index\.html
  upload: app/index\.html

Upvotes: 1

Related Questions