简体   繁体   English

在Python(GAE)中请求JavaScript属性

[英]Requesting a JavaScript property in Python (GAE)

I'm currently making an iphone web app based on Google App Engine (python). 我目前正在制作基于Google App Engine(python)的iPhone网络应用。 I need to check if the user is browsing not through safari but by the home screen. 我需要检查用户是否不是通过野生动物园而是通过主屏幕进行浏览。 I can check this with an read-only 'window.navigator.standalone' Boolean JavaScript property as read on: https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html 我可以使用只读的'window.navigator.standalone'布尔JavaScript属性对此进行检查,该属性如下所示: https : //developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html

How can I read this Boolean in Python? 如何在Python中读取此布尔值? I guess by self.request.headers.get() or something but it won't work. 我猜通过self.request.headers.get()之类的东西,但是它不起作用。

According to this page on HTTP headers and MobileSafari , you can tell if the user has launched your site from their home screen by testing to see whether the string Safari is found in the HTTP_USER_AGENT header. 根据有关HTTP标头和MobileSafari的页面 ,您可以通过测试看看是否在HTTP_USER_AGENT标头中找到了字符串Safari ,来判断用户是否从主屏幕启动了您的网站。 If it's missing, they are browsing from the home screen. 如果丢失,则表示他们正在从主屏幕进行浏览。

This seems awfully fragile (and doesn't appear to be documented outside of a couple of non-Apple blog posts), so it might not be the best thing to rely on. 这似乎非常脆弱(似乎没有在非Apple博客中发表过文章),因此这可能不是最好的依靠。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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