dshdsh2016 2014-03-19 15:50
浏览 22
已采纳

Javascript - 如何在使用Google App Engine时加载JavaScript库?

I am running Google App engine with Python, yaml. Now i need to use whichbrowser.net with it (whichbrowser is using also a PHP and the error that occure is in the

But when i am trying to load the Javascript libraries of http://whichbrowser.net/ its failing "Uncaught SyntaxError: Unexpected token < " on detect.js line 1:

detect.js:

<?php

    header("Content-Type: text/javascript");
    header("Cache-Control: no-cache, no-store, must-revalidate, max-age=0"); 
    header("Pragma: no-cache");
    header("Expires: 0"); 

    include('libraries/whichbrowser.php');

    $options = array('headers' => apache_request_headers());
    if (isset($_REQUEST['ua'])) $options['useragent'] = $_REQUEST['ua'];
    if (isset($_REQUEST['e'])) $options['engine'] = intval($_REQUEST['e']);
    if (isset($_REQUEST['f'])) $options['features'] = intval($_REQUEST['f']);
    if (isset($_REQUEST['w'])) $options['width'] = intval($_REQUEST['w']);
    if (isset($_REQUEST['h'])) $options['height'] = intval($_REQUEST['h']);
    $detected = new WhichBrowser($options);

?>

index.html:

  (function(){var p=[],w=window,d=document,e=f=0;p.push('ua='+encodeURIComponent(navigator.userAgent));e|=w.ActiveXObject?1:0;e|=w.opera?2:0;e|=w.chrome?4:0;
  e|='getBoxObjectFor' in d || 'mozInnerScreenX' in w?8:0;e|=('WebKitCSSMatrix' in w||'WebKitPoint' in w||'webkitStorageInfo' in w||'webkitURL' in w)?16:0;
  e|=(e&16&&({}.toString).toString().indexOf("
")===-1)?32:0;p.push('e='+e);f|='sandbox' in d.createElement('iframe')?1:0;f|='WebSocket' in w?2:0;
  f|=w.Worker?4:0;f|=w.applicationCache?8:0;f|=w.history && history.pushState?16:0;f|=d.documentElement.webkitRequestFullScreen?32:0;f|='FileReader' in w?64:0;
  p.push('f='+f);p.push('r='+Math.random().toString(36).substring(7));p.push('w='+screen.width);p.push('h='+screen.height);var s=d.createElement('script');
  s.src='/whichbrowser/detect.js?' + p.join('&');d.getElementsByTagName('head')[0].appendChild(s);})();

app.yaml:

- url: /whichbrowser
  static_dir: whichbrowser
  • 写回答

3条回答 默认 最新

  • dongyao5843 2014-03-19 16:48
    关注

    FYI - Google App Engine - do not allow PHP + Python to run at once. For that you need to use URL of the PHP running in another server.

    This is a really Google App Engine trap, cause when the application become larger then there is no way to move.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料