谷歌可视化API应用程序引擎不工作...(python) [英] Google visualization api on app engine not working... (python)

查看:95
本文介绍了谷歌可视化API应用程序引擎不工作...(python)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在应用引擎上的应用中呈现Google可视化API中提供的可排序表格,但它不起作用。该应用程序是用python编写的,并使用了django框架。



当我复制生成的HTML / Javascript并将其保存为本地的纯HTML文件时,它工作得很好。这导致我认为问题在于http://www.google.com/jsapi'>未包含或无法运行。



任何人否则遇到这个?我缺少app.yaml中的一些配置文件?



谢谢!

编辑:这是HTML正在制作:

 <!DOCTYPE html PUBLIC -  // W3C // DTD XHTML 1.0 Strict // ENhttp ://www.w3.org/TR/xhtml1 DTD / xhtml1-strict.dtd> 
< html xmlns =http://www.w3.org/1999/xhtml>
< head>
< title>
测试
< / title>
< link href =/ css / css.css =stylesheettype =text / css/>
< script type ='text / javascript'src ='http://www.google.com/jsapi'>< / script>
< script type ='text / javascript'>
google.load('visualization','1',{packages:['table']});
google.setOnLoadCallback(drawTable);
函数drawTable(){
var data = new google.visualization.DataTable();
data.addColumn('string','Number');
data.addColumn('string','状态');
data.addColumn('string','Nickname');
data.addColumn('string','Target');
data.addColumn('string','Recording');
data.addRows(2);

data.setCell(0,0,'0987654321');

data.setCell(0,1,'Active');

data.setCell(0,2,'Nothing');
data.setCell(0,3,'1234567890');

data.setCell(0,4,'Enabled');

data.setCell(1,0,'0987654321');

data.setCell(1,1,'Active');

data.setCell(1,2,'Nothing');
data.setCell(1,3,'1234567890');

data.setCell(1,4,'Enabled');


var table = new google.visualization.Table(document.getElementById('table_div'));
table.draw(data,{showRowNumber:true});
}
< / script>
< / head>
< body>
< div id ='table_div'>< / div>
< / body>
< / html>

如果保存为html文件,这可以正常工作。

  app.yaml:

应用程序:testapp
版本:2
运行时:python
api_version:1

处理程序:
- url:/(.*\.(mp3|wav))
static_files:\ 1
上传:(。* \。 (mp3 | wav))

- url:/ css
static_dir:css

- url:/.*
script:main.py


解决方案

如果有其他人有这个问题 - 我搞砸了标题



包括这个会杀死它:handler.response.headers [Content-Type] = text / xml


I'm trying to render the sortable table that's provided in Google visualization API in my app on app engine, but it's not working. The app is written in python and uses the django framework.

When I copy the generated HTML/Javascript and save it as a plain html file locally, it works just fine. This leads me to believe that the problem is that http://www.google.com/jsapi'> is not getting included or is not able to run.

Anyone else run into this? Am I missing some configuration piece in app.yaml?

Thanks!

EDIT: Here's the HTML that is being produced:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1 DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
 <head>
   <title> 
      Test
   </title> 
   <link href="/css/css.css" rel="stylesheet" type="text/css" /> 
    <script type='text/javascript' src='http://www.google.com/jsapi'></script> 
    <script type='text/javascript'> 
      google.load('visualization', '1', {packages:['table']});
      google.setOnLoadCallback(drawTable);
      function drawTable() {
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Number');
        data.addColumn('string', 'Status');
    data.addColumn('string', 'Nickname');
        data.addColumn('string', 'Target');
    data.addColumn('string', 'Recording');
        data.addRows(2);

        data.setCell(0, 0, '0987654321');

    data.setCell(0, 1, 'Active');

        data.setCell(0, 2, 'Nothing');
        data.setCell(0, 3, '1234567890');

    data.setCell(0, 4, 'Enabled');

    data.setCell(1, 0, '0987654321');

    data.setCell(1, 1, 'Active');

        data.setCell(1, 2, 'Nothing');
        data.setCell(1, 3, '1234567890');

    data.setCell(1, 4, 'Enabled');


       var table = new google.visualization.Table(document.getElementById('table_div'));
       table.draw(data, {showRowNumber: true});
      }
    </script> 
 </head> 
 <body> 
    <div id='table_div'></div> 
 </body> 
</html> 

This works fine if saved as an html file.

app.yaml:

application: testapp
version: 2
runtime: python
api_version: 1

handlers:
- url: /(.*\.(mp3|wav))
  static_files: \1
  upload: (.*\.(mp3|wav))

- url: /css
  static_dir: css

- url: /.*
  script: main.py

解决方案

In case anyone else has this issue - I messed up headers of the page generated by rendering with the same function I created for XML output.

Including this killed it: handler.response.headers["Content-Type"] = "text/xml"

这篇关于谷歌可视化API应用程序引擎不工作...(python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆