应用程序引擎上的 Google 可视化 api 无法正常工作...(python)

发布于 2024-08-22 20:22:29 字数 2116 浏览 5 评论 0原文

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

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

还有其他人遇到这个吗?我是否缺少 app.yaml 中的某些配置部分?

谢谢!

编辑:这是正在生成的 HTML:

    <!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> 

如果保存为 html 文件,效果很好。

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

橘虞初梦 2024-08-29 20:22:29

等等,你在哪里做渲染? Visapi 的东西在客户端。你那里有吗? (抱歉,如果这很明显;从您写问题的方式来看,这确实并不完全清楚。)

更多细节肯定会有所帮助。

Wait, where are you doing the rendering? The visapi stuff goes in the client-side. Is that where you have it? (Sorry if that's obvious; it's really not entirely clear from the way you wrote the question.)

More details would definitely help.

画离情绘悲伤 2024-08-29 20:22:29

如果其他人遇到这个问题 - 我弄乱了通过使用我为 XML 输出创建的相同函数进行渲染而生成的页面标题。

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

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"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文