webapp2

XHR responseText is empty string

安稳与你 提交于 2019-11-28 13:58:33
Html Page: <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>xhr</title> </head> <body> <script> var xhr_test = new XMLHttpRequest(); xhr_test.open("GET","xhrtest",true); xhr_test.send(); alert(xhr_test.responseText); </script> </body> </html> The main.py file: import webapp2 from handlers import cookies,pages application = webapp2.WSGIApplication([ ('/xhr',pages.XHR), ('/xhrtest', cookies.XHRTest) ], debug=True) The Request handlers: class XHRTest(webapp2.RequestHandler): def get(self): self.response.write('0') and, class XHR(webapp2.RequestHandler): def get(self): f =

How can I handle static files with Python webapp2 in Heroku?

旧巷老猫 提交于 2019-11-28 08:31:53
问题 I am now migrating my small Google App Engine app to Heroku platform. I don't actually use Bigtable, and webapp2 reduces my migration costs a lot. Now I'm stuck on handling the static files. Is there any good practices? If so, lead me there please. Thanks in advance. EDIT Well, I'm now using paste for my WSGI server. And paste.StaticURLParser() should be what I need to implement static file handler. However I have no idea how to integrate it with webapp2.WSGIApplication() . Could anyone help

Uploading Files in webapp2/GAE

余生长醉 提交于 2019-11-28 05:08:56
问题 I need to upload and process a CSV file from a form in a Google App Engine application based on Webapp2 (Python) I understand I could use blobstore to temporary store the file but I am curious to know if there is a way to process the file without having to store it at all. 回答1: The content of uploaded files is in self.request.POST in your handler, so you can get that content (assuming e.g the field for the uploaded file is named 'foo' ) with e.g content = self.request.POST.multi['foo'].file

Issue with sending XML to Web Api via http Post request

♀尐吖头ヾ 提交于 2019-11-28 04:52:29
问题 I would like to send the following XML document to my Web Api 2 controller; however, the [FromBody] parameter is always null. Here is the request XML body: <razorInbound server="PortfolioExposureServer" request="lookupRiskPointRecord"> <caller>RazorClient</caller> <responseMode>xml</responseMode> <body> <conditions> <fromOffset>0</fromOffset> <top>100</top> <condition> <keyPath> <keyElement nodeOffset='1'>Currency</keyElement> <keyElement nodeOffset='2'>ID</keyElement> </keyPath> <lookupValue

Webapp2 for Authentication and Login

廉价感情. 提交于 2019-11-28 04:09:34
I would like to roll my own login system for my python Google App Engine application (rather than using Google's users api ). I am using webapp2, and I noticed that there is a webapp2_extras.auth module and an incomplete auth tutorial . Does anyone know how I can use this API to create: User Registration (take an email and password, and perhaps verify email) User Login with email and password Once I have the email and password, where do I store it? In the AuthStore? And how do I authenticate against the AuthStore? How and where you store user credentials and information is entirely up to you;

How to properly output JSON with app engine Python webapp2?

穿精又带淫゛_ 提交于 2019-11-27 18:21:00
Right now I am currently just doing this: self.response.headers['Content-Type'] = 'application/json' self.response.out.write('{"success": "some var", "payload": "some var"}') Is there a better way to do it using some library? Yes, you should use the json library that is supported in Python 2.7: import json self.response.headers['Content-Type'] = 'application/json' obj = { 'success': 'some var', 'payload': 'some var', } self.response.out.write(json.dumps(obj)) Xuan webapp2 has a handy wrapper for the json module: it will use simplejson if available, or the json module from Python >= 2.6 if

GAE webapp2 session: the correct process of creating and checking sessions

瘦欲@ 提交于 2019-11-27 17:54:42
I tried to implement GAE's webapp2 session, but there seems very little documentation about it. According to http://webapp-improved.appspot.com/api/webapp2_extras/sessions.html , my steps are as follows: 1.Configure and add config to the main application: config = {} config['webapp2_extras.sessions'] = { 'secret_key': 'my_secret_key', } app = webapp2.WSGIApplication([...], config=config) 2.Create session in the login handler # Delete existent session --> not mention in the tutorial # member is found self.session_store = sessions.get_store(request=handler.request) self.session['account'] =

Maintain uniqueness of a property in the NDB database

扶醉桌前 提交于 2019-11-27 16:12:15
问题 An NDB model contains two properties: email and password . How to avoid adding to the database two records with the same email ? NDB doesn't have UNIQUE option for a property, like relational databases do. Checking that new email is not in the database before adding—won't satisfy me, because two parallel processes can both simultaneously do the checking and each add the same email . I'm not sure that transactions can help here, I am under this impression after reading some of the manuals.

Memory leak in Google ndb library

核能气质少年 提交于 2019-11-27 14:11:30
I think there is a memory leak in the ndb library but I can not find where. Is there a way to avoid the problem described below? Do you have a more accurate idea of testing to figure out where the problem is? That's how I reproduced the problem : I created a minimalist Google App Engine application with 2 files. app.yaml : application: myapplicationid version: demo runtime: python27 api_version: 1 threadsafe: yes handlers: - url: /.* script: main.APP libraries: - name: webapp2 version: latest main.py : # -*- coding: utf-8 -*- """Memory leak demo.""" from google.appengine.ext import ndb import

CORS - Using AJAX to post on a Python (webapp2) web service

久未见 提交于 2019-11-27 12:46:33
问题 This is going to be long: Ok so I'm developing a google calendar gadget which sends requests to a Python webapp2 REST api hosted on Google App Engine. The problem comes when I try to POST something it doesn't allows me because of CORS. In Chromes' DevTools it says: 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