webapp2

webapp2.Route with optional leading part

一世执手 提交于 2020-01-03 15:35:33
问题 I am learning the webapp2 framework with its powerful Route mechanism. My application is supposed to accept URIs like these: /poll/abc-123 /poll/abc-123/ /poll/abc-123/vote/ # post new vote /poll/abc-123/vote/456 # view/update a vote Polls may optionally be organized into categories, so all the above should work also like this: /mycategory/poll/abc-123 /mycategory/poll/abc-123/ /mycategory/poll/abc-123/vote/ /mycategory/poll/abc-123/vote/456 My incorrect configuration: app = webapp2

Can't get POST parameters

人走茶凉 提交于 2020-01-02 07:45:29
问题 I'm developing a web app in Python using WebApp2 as framework. I can't get the http POST request parameters submitted by filling a form. That's the HTML code of the form I created <html> <head> <title>Normal Login Page </title> </head> <body> <form method="post" action="/loginN/" enctype="text/plain" > eMail: <input type="text" name="eMail"><br/> password: <input type="text" name="pwd"><br/> <input type="submit"> </form> </body> That's the result of the POST request after pressing the submit

How to solve a UnicodeDecodeError?

空扰寡人 提交于 2020-01-02 03:11:29
问题 I get a strange error message when trying to read non-ascii from the datastore: 'ascii' codec can't decode byte 0xc3 in position 5: ordinal not in range(128) Traceback (most recent call last): File "/base/data/home/apps/s~myapp-www/events.355951895377615944/webapp2.py", line 1511, in __call__ rv = self.handle_exception(request, response, e) File "/base/data/home/apps/s~myapp-www/events.355951895377615944/webapp2.py", line 1505, in __call__ rv = self.router.dispatch(request, response) File "

How to solve a UnicodeDecodeError?

一个人想着一个人 提交于 2020-01-02 03:11:12
问题 I get a strange error message when trying to read non-ascii from the datastore: 'ascii' codec can't decode byte 0xc3 in position 5: ordinal not in range(128) Traceback (most recent call last): File "/base/data/home/apps/s~myapp-www/events.355951895377615944/webapp2.py", line 1511, in __call__ rv = self.handle_exception(request, response, e) File "/base/data/home/apps/s~myapp-www/events.355951895377615944/webapp2.py", line 1505, in __call__ rv = self.router.dispatch(request, response) File "

GAE Webapp2 - destroying session doesn't work

为君一笑 提交于 2019-12-30 07:11:33
问题 Or do I misunderstand how destroying work? Here's an example code: class TestHandler(BaseHandler): def get(self): counter = self.session.get('counter') if not counter: counter = 0 counter += 1 if counter > 5: self.auth.unset_session() else: self.session['counter'] = counter return self.response.write ( counter ) Session works, the counter counts, but either session isn't destroyed or destroying it doesn't null the value? Does destroying null only some values like userid and sessionid or do I

Memory leak in Google ndb library

痴心易碎 提交于 2019-12-28 04:04:29
问题 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

Partial matching GAE search API

我的梦境 提交于 2019-12-27 17:32:51
问题 Using the GAE search API is it possible to search for a partial match? I'm trying to create autocomplete functionality where the term would be a partial word. eg. > b > bui > build would all return "building". How is this possible with GAE? 回答1: Though LIKE statement (partial match) is not supported in Full Text Search, but you could hack around it. First, tokenize the data string for all possible substrings (hello = h, he, hel, lo, etc.) def tokenize_autocomplete(phrase): a = [] for word in

Webapp2 - TypeError: get() takes exactly 1 argument (2 given)

狂风中的少年 提交于 2019-12-25 09:06:05
问题 I have a /consults page displaying a list of consults. My list loop looks like this: {% for consult in consults %} <tr> <td><a href="/consults/view-consult?key={{consult.key.urlsafe()}}">{{ consult.consult_date }}</a></td> <td>{{ consult.consult_time }}</td> <td>{{ consult.patient_first }}</td> <td>{{ consult.patient_last }}</td> <td><span class="badge badge-warning">{{ consult.consult_status }}</span></td> </tr> {%endfor%} So I'm using the url to send a Consult key to the individual page to

Django on GoogleAppEngine - Performance?

随声附和 提交于 2019-12-25 05:04:12
问题 Does running Django on GoogleAppEngine, as opposed to the default WebApp2 framework, consume additional resources? Any metrics? 回答1: From the mailing list, I've seen multiple comments on Django instances taking significantly longer to start up if cold. This would be noticeable if your app is rarely used. From my app's log it looks like the first request took about 4 seconds to start up. My Django instances use 41-43MB. Not sure about webapp2. If you're using Django-nonrel as an ORM, I'm sure

CSS Files not working on localhost

做~自己de王妃 提交于 2019-12-25 03:56:06
问题 The problem is just happening on localhost, when I upload the application to AppEngine, It succesfully finds the css files. I'm using python 2.7, the app is done on webapp2 and I'm using a local copy of bootstrap. <link href="/static/bootstrap/css/bootstrap.css" rel="stylesheet" media="screen"> <link href="/static/bootstrap/css/bootstrap-responsive.css" rel="stylesheet"> Those are my links to the css files, they work when I deploy the app http://main-cocoa-597.appspot.com/cenira, but they don