- https://github.com/ampproject/amphtml/tree/master/examples
- https://github.com/ampproject/amphtml/tree/master/examples/metadata-examples
- https://github.com/ampproject/amphtml/tree/master/extensions#access
Debug this
Debug this
| class MainHandler(http2.PushHandler): | |
| def get(self): | |
| name = os.path.join(os.path.dirname(__file__), 'dist/static/data/', self.request.path.lstrip("/amphtml/"), 'index.json') | |
| f = open(name, 'r'); | |
| c = f.read() | |
| f.close() | |
| data = json.loads(c) | |
| data['article'] = unescape(data['article']) | |
| data['permalinkamp'] = data['permalink'].replace(".com", ".com/amphtml") | |
| bot_template = os.path.join(os.path.dirname(__file__), 'dist/static/amphtml/index.html') | |
| return self.response.write(template.render(bot_template, data)) | |
| app = webapp2.WSGIApplication([ | |
| ('/.*', MainHandler) | |
| ], debug=True) |
| <!doctype html> | |
| <html ⚡ lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Hello, AMPs</title> | |
| <link rel="canonical" href="http://example.ampproject.org/article-metadata.html" /> | |
| <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"> | |
| <script type="application/ld+json"> | |
| { | |
| "@context": "http://schema.org", | |
| "@type": "NewsArticle", | |
| "headline": "Open-source framework for publishing content", | |
| "datePublished": "2015-10-07T12:02:41Z", | |
| "image": [ | |
| "logo.jpg" | |
| ] | |
| } | |
| </script> | |
| <style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript> | |
| <script async src="https://cdn.ampproject.org/v0.js"></script> | |
| </head> | |
| <body> | |
| <h1>Welcome to the mobile web</h1> | |
| </body> | |
| </html> |
| <amp-analytics type="googleanalytics" config="https://example.com/analytics.account.config.json"> | |
| <script type="application/json"> | |
| { | |
| "requests": { | |
| "pageview": "https://example.com/analytics?url=${canonicalUrl}&title=${title}&acct=${account}", | |
| "event": "https://example.com/analytics?eid=${eventId}&elab=${eventLabel}&acct=${account}" | |
| }, | |
| "vars": { | |
| "account": "ABC123" | |
| }, | |
| "extraUrlParams": { | |
| "cd1": "AMP" | |
| }, | |
| "triggers": { | |
| "trackPageview": { | |
| "on": "visible", | |
| "request": "pageview" | |
| }, | |
| "trackAnchorClicks": { | |
| "on": "click", | |
| "selector": "a", | |
| "request": "event", | |
| "vars": { | |
| "eventId": "42", | |
| "eventLabel": "clicked on a link" | |
| } | |
| } | |
| }, | |
| 'transport': { | |
| 'beacon': false, | |
| 'xhrpost': false, | |
| 'image': true | |
| } | |
| } | |
| </script> | |
| </amp-analytics> |