Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Angularjs和Google应用程序引擎Python服务器上使用POST_Python_Google App Engine_Angularjs - Fatal编程技术网

在Angularjs和Google应用程序引擎Python服务器上使用POST

在Angularjs和Google应用程序引擎Python服务器上使用POST,python,google-app-engine,angularjs,Python,Google App Engine,Angularjs,我这里有个问题 我一直在使用$resource来执行simpleget,但最近我有大量数据要发送到服务器,但给出的414错误URI太大。我知道解决方法之一是使用POST而不是GET 我试图搜索诸如$http.post之类的解决方案,并将参数传递给$http,但没有结果。有人能给我一个如何做的指导吗 编辑: 以下是我所做的: var data_2 = $.param({'method':"update_proj", 'proj_id': proj_id,

我这里有个问题

我一直在使用$resource来执行simpleget,但最近我有大量数据要发送到服务器,但给出的414错误URI太大。我知道解决方法之一是使用POST而不是GET

我试图搜索诸如$http.post之类的解决方案,并将参数传递给$http,但没有结果。有人能给我一个如何做的指导吗

编辑:

以下是我所做的:

    var data_2 = $.param({'method':"update_proj",
            'proj_id': proj_id,
            'ptitle': project.title,
            'pdescription': p_desc,
            'pexposure': tech,
            'pcompany': project.company,
            'pteamsize':project.teamsize,
            'ppoc': project.poc,
            'pemail': c_email,
            'pcontact': project.contact,
            'pimg':project.img,
            'pvideo':project.video,
            'prskill': rskills,
            'poutcome': project.outcome});

    $http({method:'update_proj',
      url: "http://osmosisgal.appspot.com/update_proj", 
      data: data_2,
      headers: {'Content-Type': 'application/x-www-form-urlencoded'}})
    .success(function(data,status){
     ...
    });
以下是我在GAE上的python代码:

    class ActionHandler(webapp.RequestHandler):
       def update_project(self):
           proj_id = self.request.POST["proj_id"]
               .
               .
               .
但我仍然有这个错误

Traceback (most recent call last):
  File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
  File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__
    rv = self.router.dispatch(request, response)
  File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1102, in __call__
    return handler.dispatch()
  File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "/python27_runtime/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "/base/data/home/apps/s~osmosisgal/1.366101252356646323/new_backend.py", line 1274, in update_project
    proj_id = self.request.POST["proj_id"]
  File "/python27_runtime/python27_lib/versions/third_party/webob-1.1.1/webob/multidict.py", line 312, in __getitem__
    return self._decode_value(self.multi.__getitem__(self._encode_key(key)))
  File "/python27_runtime/python27_lib/versions/third_party/webob-1.1.1/webob/multidict.py", line 568, in __getitem__
    raise KeyError("No key %r: %s" % (key, self.reason))
KeyError: "No key 'proj_id': Not a form request"
从中可以看出,该方法首先获取的是方法的类型,而不是url

$http({method: 'POST', url: '/someUrl', data: my_data}).
  success(function(data, status, headers, config) {
    // this callback will be called asynchronously
    // when the response is available
  }).
  error(function(data, status, headers, config) {
    // called asynchronously if an error occurs
    // or server returns response with an error status.
  });
对于您的数据,您可以使用pairs、key-value创建一个json对象,并将其传递给上述函数

另外,不要忘记在控制器定义中传递$http

function MyController($scope, $http) {...}; 

我设法解决了它。最初我没有在GAE中托管所有静态文件,托管后,一切正常。

来自:
$http.post('/someUrl',data.).success(successCallback)。你有没有试着这样搜索一些例子?:我试过了,但没有成功。它给了我这些错误:选项500(内部服务器错误)XMLHttpRequest无法加载。Access-Control-Allow-Origin不允许使用Origin null。请尝试在数据之后传递变量,
标题:{'Content-Type':'application/x-www-form-urlencoded'}