简体   繁体   English

如何在Google App Engine HTTP响应中包括图形和表格

[英]How to include graphs and tables in Google App Engine HTTP Response

I am building an application where audio data is uploaded to my GAE server, processed, and displayed as a response to an HTTP GET request. 我正在构建一个将音频数据上传到我的GAE服务器,进行处理并显示为对HTTP GET请求的响应的应用程序。

Part of the data I wish to display is in the format of a graph. 我希望显示的部分数据为图形格式。 What I am having a hard time understanding is how to create my response in such a way that I can include graphs. 我很难理解的是如何以可以包含图表的方式创建我的响应。

From what I understand, one approach might be to create the graph using this API: http://googleappsdeveloper.blogspot.ca/2011/09/visualize-your-data-charts-in-google.html And then store it as a blob in my datastore. 据我了解,一种方法可能是使用以下API创建图形: http : //googleappsdeveloper.blogspot.ca/2011/09/visualize-your-data-charts-in-google.html ,然后将其存储为我的数据存储区中的Blob。 I can then create a JSP to serve the blob as an image? 然后,我可以创建一个JSP来将Blob用作图像吗? Not sure if I am understanding this correctly. 不知道我是否理解正确。 Specifically, I'm not sure about being able to access all of this functionality from GAE, and if I'm doing this in a convoluted way. 具体来说,我不确定是否可以从GAE访问所有这些功能,并且是否以复杂的方式进行操作。

I am quite new to GAE and web programming in general, so I greatly appreciate feedback and suggestions on how to do this in the simplest/quickest way. 一般而言,我对GAE和Web编程还很陌生,因此,我非常感谢您以最简单/快速的方式获得反馈和建议。 I wouldn't mind links to relevant resources as well. 我也不介意链接到相关资源。

you have mainly two ways to go: 您主要有两种方法:
1) Send in your response only data and let your front end (your website or app) parse them and put them in graph form. 1)仅发送您的响应数据,并让您的前端(您的网站或应用程序)解析它们并将其以图表形式显示。 You can write in your response the data to show, and it is quite suggested to give them a structure (so as your front-end can easily interpret and validate the data). 您可以在响应中写出要显示的数据,强烈建议给它们一个结构(以便您的前端可以轻松地解释和验证数据)。 Common formats are JSON and XML (they basically can give a custom hierarchical structure to your data,for example you can organize the graph data in columns form) 常见格式为JSON和XML(它们基本上可以为数据提供自定义的层次结构,例如,您可以以列的形式组织图形数据)
The way to build a graph depends on the technology you use in your front-end and you can either use a third part library or build your own 建立图表的方式取决于您在前端使用的技术,您可以使用第三方库也可以建立自己的库

2) Create graphs in your web application, store them and allow users to get them via HTTP. 2)在您的Web应用程序中创建图形,进行存储,并允许用户通过HTTP获取图形。 Once you have found a way to build a graph image from data you need to store it. 一旦找到了一种根据数据构建图形图像的方法,就需要存储它。 GAE gives to you two storage systems, the Blobstore and the Google Cloud Storage. GAE为您提供了两个存储系统,即Blobstore和Google Cloud Storage。
I think You can save files in the Blobstore only by direct upload via HTTP therefore if you're saving image directly in your GAE web app there's no easy way to use it (you should open an HTTP connection). 我认为您只能通过通过HTTP直接上传将文件保存在Blobstore中,因此,如果直接将图像保存在GAE网络应用中,则没有简单的使用方式(您应该打开HTTP连接)。
The Google cloud storage instead can be accessed by using the dedicated libraries ( https://developers.google.com/appengine/docs/java/googlecloudstorageclient/getstarted ) that you need to download and add to your project during the developing phase (and activate them) there are tutorials for this ( https://developers.google.com/appengine/docs/java/googlecloudstorageclient/ ). 相反,您可以使用专用库( https://developers.google.com/appengine/docs/java/googlecloudstorageclient/getstarted )访问Google云存储,您需要在开发阶段将其下载并添加到项目中(并且激活它们)有针对此的教程( https://developers.google.com/appengine/docs/java/googlecloudstorageclient/ )。

In order to serve images you can bypass the middle code that should read the image from the GCS and serve it as a response by using the Images service. 为了提供图像,您可以绕过应该从GCS读取图像并使用“图像”服务作为响应的中间代码。 Once generated a so called "serving URL" associated to a given image, the images service permits to directly access to the image via HTTP ( https://developers.google.com/appengine/docs/java/images/ ). 一旦生成了与给定图像相关的所谓的“服务URL”,图像服务就可以通过HTTP( https://developers.google.com/appengine/docs/java/images/ )直接访问图像。

Finally the first option is interesting because (obviously if you can) it's simpler and lighter for the server side (the one you pay) and you can anyway cache the images to avoid useless computation, the second is maybe more correct in a certain point of view but it is more complex. 最后,第一个选择很有趣,因为(显然,如果可以的话)它对于服务器端(您支付的那个)更简单,更轻便,并且您仍然可以缓存图像以避免无用的计算,第二个选择在某些方面可能更正确视图,但更为复杂。

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

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