Tag: google app engine

使用Jquery blueimp将图像上传到App Engine:

有人可以指点我使用JQuery blueimp插件实现多个图像上传到Java应用程序引擎blobstore吗? 文档有一个maven实现,但我理解将现有项目移植到Maven很棘手,我想避免这一步。 谢谢

jQuery AJAX GET / POST请求在error handling程序中返回404,但是从服务器发送了有效响应

问题:我用jQuery.ajax发送GET或POST请求,并获得用404触发的error handling程序。问题是,我使用嗅探器检查服务器的答案,它是一个有效的200响应,具有正确的JSON(返回通过Python json.dumps)。 而且有些奇怪:在这次调用结束后,浏览器会重新加载页面。 一切都生活在同一个域(也是子域)。 jQuery调用: $.ajax({type: “POST”, url: “/m/auth/login”, data: {x: “y”}, success: function(result) {}, error: function(xhr) {}, dataType: “json”}); 具有有效负载解压缩的嗅探器看到的响应: HTTP/1.1 200 OK\r\n Content-Type: text/html; charset=utf-8\r\n Cache-Control: no-cache, must-revalidate\r\n Content-Encoding: gzip\r\n X-AppEngine-Estimated-CPM-US-Dollars: $0.000018\r\n X-AppEngine-Resource-Usage: ms=71 cpu_ms=0\r\n Vary: Accept-Encoding\r\n Date: Tue, 24 Dec 2013 21:04:36 GMT\r\n Pragma: no-cache\r\n Expires: Fri, 01 Jan 1990 00:00:00 […]

AjaxForm和app引擎blobstore

我在AjaxForm文件上传和app引擎blobstore方面遇到了一些困难。 我怀疑难度是因为blobstore上传处理程序(blobstore_handlers.BlobstoreUploadHandler的子类)要求重定向响应,而不是返回任何内容,但我不确定。 我希望得到一个XML文档,它似乎按预期到达浏览器,但我无法掌握它 – 详情如下。 我的app引擎blobstore上传处理程序如下 – class UploadHandler(blobstore_handlers.BlobstoreUploadHandler): def post(self): upload_files = self.get_uploads(‘file’) # ‘file’ is file upload field in the form blob_info = upload_files[0] entity_key = self.request.get(“entityKey”) // Update a datastore entity with the blobkey (not shown) // redirect to the uri for the updated entity self.redirect(‘%s.xml’ % entity_key) 最后的重定向是我的应用程序中的uri,它返回一个xml文档。 查看服务器输出,没有迹象表明出现任何问题 – 重定向已得到服务,并且按预期返回xml文档,并使用正确的mime类型 […]

使用https而不是http时,JSONP请求失败

我有一个API客户端,它使用JQuery发出JSONP请求。 当使用SSL时,此API客户端不使用SSL时,一切正常。 例如,我有一个URL http://apiclient.com ,我正在从这个域发出以下JSONP请求: $.ajax({ url: url, dataType: “jsonp”, contentType: “application/json; charset=utf-8”, success: function(data) { $.each(data.services, function(index, service) { processService(service); }); } }); 我看到对url中指定的API主机做出了适当的请求, 成功的回调函数通过传递给它的格式正确的数据被正确调用。 但是,当我将API客户端的上述URL更改为https://apiclient.com时 ,API主机上未发现任何请求。 我发现日志的任何一方都没有错误。 注意:API客户端唯一的区别是http到https 。 使用https域时,您是否需要以不同方式处理JSONP请求? 谢谢。 修改:此问题仅适用于Chrome。 它适用于Firefox和Safari。 但是我在FireFox上收到一个快速警告,询问我是否要从加密站点发出未加密的请求。 我允许它,再也没有看到警告。

CORS – 使用AJAX在Python(webapp2)Web服务上发布

这将是漫长的: 好的,我正在开发一个谷歌日历小工具,它将请求发送到托管在Google App Engine上的Python webapp2 REST api。 当我尝试发布因CORS而不允许我发布的内容时,问题就来了。 在Chromes的DevTools中它说: Method: OPTIONS. Status: (failed) Request header field Content-Type is not allowed by Access-Control-Allow-Headers. Origin https://hq34i4geprnp5vci191ljfuhcoerscl4-a-calendar-opensocial.googleusercontent.com is not allowed by Access-Control-Allow-Origin. 我知道这是因为CORS。 这里: Ajax – Access-Control-Allow-Origin不允许使用Origin localhost 它说我必须添加 Access-Control-Allow-Origin: * 对于标题,但是我又是ajax的新手,我想知道它是否以这种方式完成: $.ajax({ type: “POST”, url: “https://myapp.appspot.com/service”, contentType: “application/json; charset=utf-8”, data: data, beforeSend: function (request) { request.setRequestHeader(“Access-Control-Allow-Origin”, “*”); […]

静态文件丢失

在我的应用程序中有一个/static文件夹,其中包含应用程序所需的所有静态资源。 这是我的静态资源处理程序: – url: /static static_dir: static 这适用于直接在/static文件,但是假设我还有另一个包含jQuery的文件夹: static |- jquery | \- jquery.js | \- images \- … 当我尝试访问[myapp].appspot.com/static/jquery/jquery.js ,它将返回404并且我不知道为什么。 我的一些文件,包括.css和.ttf等,给我一个Could not guess mimtype错误。 我不知道如何解决这个问题。 编辑 添加了我的(新)app.yaml。 我没有dispatch.yaml。 version: 1 runtime: python27 api_version: 1 threadsafe: true handlers: – url: /static/pages_style mime_type: text/css static_dir: /static/pages_style – url: /static/images/(.*\.(gif|png|jpg))$ static_files: static/images/\1 upload: static/images/.*\.(gif|png|jpg)$ – url: /static/bootstrap […]