webapp2

webapp2, Jinja2: how to cut large html file into multiple html files

本小妞迷上赌 提交于 2019-12-04 15:34:06
When I blog, I like to separate each blog-post into its own .html file (is that ok?) This prevents the file getting too big, and makes it easy to go back and edit a previously written blog post if need be. Occasionally the blog post will contain css/js/ajax/template variables. But on my website, I like all the blog posts on one page (so I can scroll through them all, instead of going to a separate page for each post) Here is an html file that contains two blog posts: {% extends "base.html" %} {% block blog_posts %} <!-- links/targest for the side menu to jump to a post --> <li><a href="#post2"

How to parse an Angular POST request in WebApp2

前提是你 提交于 2019-12-04 10:51:15
问题 How do I get data from my Angular POST request in Google App Engine WebApp2? self.request.body returns a string, and self.request.get(key) returns nothing. The Angular code that submits the POST is: $http.post("/mail", {request_name: 'Test Name', request_body: 'Test Body'}); Then these two lines in my WebApp2 handler: print "1: " + self.request.body print "2: " + self.request.get('request_name') Print this: 1: {"request_name":"Test Name","request_body":"Test Body"} 2: What is the best way get

Django vs webapp2 on App Engine [closed]

淺唱寂寞╮ 提交于 2019-12-04 10:44:08
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . I would like to know your opinion of which of these two web frameworks (Django & webapp2) is better for using on App Engine Platform,

AppEngine: No module named pyasn1.compat.binary

限于喜欢 提交于 2019-12-04 05:23:33
问题 I keep getting the following error when hitting my AppEngine server: ERROR 2017-09-20 07:16:06,978 wsgi.py:263] Traceback (most recent call last): File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler handler, path, err = LoadObject(self._handler) File

PATCH method handler on Google AppEngine WebApp2

空扰寡人 提交于 2019-12-04 02:04:57
I tried to use a def patch(): method in my webapp2.RequestHandler to support partial resource updates, but then saw that the allowed methods are frozen in webapp2.py: allowed_methods = frozenset(('GET', 'POST', 'HEAD', 'OPTIONS', 'PUT', 'DELETE', 'TRACE')) How can I extend webapp2.RequestHandler or modify the WSGIApplication class to allow the PATCH HTTP method when deployed on Google AppEngine? Just use a monkey patch by performing this before creating a WSGIApplication : allowed_methods = webapp2.WSGIApplication.allowed_methods new_allowed_methods = allowed_methods.union(('PATCH',)) webapp2

Decoding JSON with python using Appengine

不问归期 提交于 2019-12-03 21:40:52
I have the following code which retrieves values from a simple 3 input form: //retrieves data from a form var $form = $( this ), prgname= $form.find('input[name="prg"]').val(), startDate = $("#startdate").datepicker({ dateFormat: 'yy-mm-dd' }).val(), endDate = $("#enddate").datepicker({ dateFormat: 'yy-mm-dd' }).val(); The following code sends the request to the server: var request = $.ajax({ url: "/prg/", type: "post", data: JSON.stringify({prg: prgname, start:startDate, end:endDate}), contentType: 'application/json', dataType: 'json', success: function() {}, error: function (jqXHR,

webapp2 under Apache (= without Google App Engine)

痞子三分冷 提交于 2019-12-03 16:46:11
I am trying to run webapp2 under Python with Apache and mod_wsgi - specifically: Wampserver for Windows 7 with Apache 2.2.22. So far, I have failed miserably. :-( I used the following example from https://developers.google.com/appengine/docs/python/gettingstartedpython27/usingwebapp : import webapp2 class MainPage(webapp2.RequestHandler): def get(self): self.response.headers['Content-Type'] = 'text/plain' self.response.out.write('Hello, webapp World!') app = webapp2.WSGIApplication([('/', MainPage)], debug=True) When I save this file as c:wamp\www\Python\hello.py , and browse to localhost

GAE: Enabling Edge Cache with webapp2 (Python)

风格不统一 提交于 2019-12-03 16:41:23
There has been this new video on youtube demonstrating the strength of EdgeCaching in the GAE architecture, and at this particular point in the video they demonstrate how easy it is to leverage: http://www.youtube.com/watch?v=QJp6hmASstQ#t=11m12 Unfortunately it's not that easy... I'm looking to enable edge caching using the webapp2 framework provided by Google. I'm calling: self.response.pragma = 'Public' self.response.cache_expires(300) but it seems overridden by something else. The header I get is: HTTP/1.1 200 OK Pragma: Public Cache-Control: max-age=300, no-cache Expires: Sat, 23 Feb 2013

Simple Python and Ajax Example How to Send Response with Python?

馋奶兔 提交于 2019-12-03 16:35:13
I am testing out some code with Python and Javascript trying to get an Ajax system set up. Basically I just want to input a word and have the python code send it back. Here is my html/javascript: <html> <head> <title>Simple Ajax Example</title> <script language="Javascript"> function xmlhttpPost(strURL) { var xmlHttpReq = false; var self = this; // Mozilla/Safari/Chrome if (window.XMLHttpRequest) { self.xmlHttpReq = new XMLHttpRequest(); } // IE else if (window.ActiveXObject) { self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP"); } self.xmlHttpReq.open('POST', strURL, true); self

Google App Engine HTTP header Content-Type not correct once application is deployed

半腔热情 提交于 2019-12-03 16:03:42
I am writing an app on GAE and I have a URL that will always return XML and set the Content-Type to "text/xml; charset=utf-8" . I am using the built in webapp framework and using the following code to set content type and return XML in the web handler: self.response.headers.add_header('Content-Type',"text/xml; charset=utf-8") self.response.out.write(template.render("my_xml",{"key1":"val1"})) This works fine on the local development environment but once I deploy to the Google servers the content type is always set to "text/html; charset=utf-8" . How do I make sure that correct Content-Type is