python,google-app-engine,webapp2
You could first catch ALL requests to the "www" subdomain: from webapp2_extras.routes import DomainRoute app = webapp2.WSGIApplication([ DomainRoute('www.domain.com', [ webapp2.Route(r'/<:.*>', handler=RedirectWWW), ]), ('/', IndexPage), ('/discover', DiscoverPage), ('/about', AboutPage), ('/help', HelpPage), ('/terms-and-privacy', TermsPage) ], debug=True) with a handler that replaces the www part with the naked domain: class RedirectWWW(webapp2.RequestHandler): def get(self,...
python,google-app-engine,blobstore,webapp2
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.read() So now you have the content as a string -- process it as you wish. This does...
google-app-engine,webapp2,gae-sessions
I think storing in database and doing a query on each request is the most natural option. Don't know about your full requirements and specifications, but for keeping the sessions synchronized I think a solution like firebase makes a lot of sense, though it might be overkill in your case....
python,google-app-engine,datastore,webapp2
You can get a key of a parent entity from the key of your child entity. Look at the key Class: https://developers.google.com/appengine/docs/python/datastore/keyclass#Key_parent...
webapp2 does some magic on routes (converting from the tuples to webapp2.Route instances). When you just assign to routes, it won't work because they haven't been converted to the right format for webapp2. I believe you can just add in the Route instantiation and it should work.
python,google-app-engine,inheritance,webapp2
Try changing: class BlogHandler(webapp2.RequestHandler): def __init__(self, request=None, response=None): self.is_logged_in = False super(BlogHandler, self).__init__(request, response) Putting your attribute before your call to super....
python,google-app-engine,google-cloud-storage,webapp2
enctype is an attribute of the form tag: <form action="/upload_data" method="post" enctype="multipart/form-data"> <input type="file" name="add_scanned_data_file"> <input type="image" src="stylesheets/add_data.png" alt="submit" align="left"> </form> ...
python,google-app-engine,google-cloud-storage,webapp2
def CreateFile(filename,imageFile): with gcs.open(filename, 'w', content_type = 'image/jpeg') as f: f.write(imageFile) f.close() blobstore_filename = '/gs' + filename return blobstore.create_gs_key(blobstore_filename) class MyImageHandler(webapp2.RequestHandler): def post(self): bucket='youbucketname' imageFile = self.request.get('file') nameOfFile = self.request.get('filename1') fileName = '/youbucketname' + '/' + nameOfFile blob_key = CreateFile(fileName, imageFile) imageUrl = 'https://%(bucket)s.storage.googleapis.com/%(file)s' %...
python,google-app-engine,webapp2
I see two ways how to do that. First is to inherit from the UserToken class making user an indexed property. Then you can set the token_model class property to your new token model in your user class. Here is the code: class MyToken(UserToken): user = ndb.StringProperty(required=True) class MyUser(User): token_model...
python,html,html5,http,webapp2
Short answer: The issue is not with the web framework or the browser. This is an HTML limitation. HTML only allows for GET and POST. No other methods are permitted. I've adjusted my title to reflect the subject matter more accurately. More details: Based on the HTML clue from @Greg,...
python,image,google-app-engine,app-engine-ndb,webapp2
Use the image service and the images will be served from a high speed image serving service that'll probably be closer to your end users in any case then anything you could arrange yourself in GAE. https://developers.google.com/appengine/docs/python/images/functions get_serving_url(blob_key, size=None, crop=False, secure_url=None) Returns a URL that serves the image. This URL...
google-app-engine,url-routing,webapp2
Route like '/users/' will catch all requests on '/users/*', so you can fix your problem by changing the order of routes: _route = [ RedirectRoute('/', 'home.HomeHandler', name='home', strict_slash=True), RedirectRoute('/users/comments/new/', 'users.UserNewCommentHandler', name='new-comment', strict_slash=True) RedirectRoute('/users/<usercode>', 'users.UserSingleHandler', name='user-page', strict_slash=True), ] ...
Your mypdf.pdf is not set up as application readable. You can do that in app.yaml - url: /mypdf.pdf static_files: mypdf.pdf upload: mypdf.pdf application_readable: true ...
python,google-app-engine,google-cloud-endpoints,webapp2,google-datastore
Yes, that's a perfectly reasonable approach. If you are using Cloud Endpoints and NDB, you may want to look at the Endpoints Proto Datastore API which takes some of the legwork out of serializing your NDB Model entities. Personally, I didn't find the API very intuitive so I reverted to...
python,google-app-engine,python-2.7,webapp2
You can control execution time in queue.yaml, by setting rate to 10/s for example. Be sure that your module configuration is set to auto scaling, or use proper manual scaling. queue: - name: default rate: 5/s Also take a look into your logs and look for failing tasks, which could...
python,google-app-engine,jinja2,webapp2
For starters, the purpose of verbose_name is to use it in the label, not as the name of the input. It's better if the name matches the model (for clarity and future automation), and I don't think it'll change often (if at all), because that requires a lot of work...
google-app-engine,session,webapp2
Use a urlsafe version of the key: https://cloud.google.com/appengine/docs/python/ndb/entities#retrieving_entities self.session['client'] = client.key.urlsafe() On retrieval, use client = ndb.Key(urlsafe=self.session['client']).get() ...
python,google-app-engine,authentication,gae-datastore,webapp2
You should look into managing sessions in webapp2. Basically what need to happen is, user1 has to login, and you'll store the login info (eg user id) in the session. Whenever the url www.example.com/ViewFriendsFruits?id=user2id is hit, you'll want to check if there is currently user logged in (by checking the...
google-app-engine,python-2.7,jinja2,app-engine-ndb,webapp2
Counter information is persistent, you don't have another option than writing it to datastore. For a more efficient and fast implementation i would invite you to check out Sharding counters...
python,regex,google-app-engine,url-redirection,webapp2
Change the order of the rules and you should be fine. Later on, when you'll see that nobody is actually visiting the old URLs you could just delete this handler. app = webapp2.WSGIApplication([ ('/', Home), ('/get/something', AnotherHandler), ('/(.+)/?', oldPathsHandler), ], debug = True) ...
javascript,json,laravel,amazon-s3,webapp2
Simple answers such as which frameworks, tools etc to use is more than fine. Willing to learn! ;) Your question is too general, there isn't a one right way or a framework/tools that does this task better/worse than others, it just depends on how you want and how you...
python,google-app-engine,cookies,logout,webapp2
The browser usually sends along the page the user came from, with the HTTP Referer (sic) header. Because of privacy concerns, not all browsers send this, or they may falsify it or only send if the next page requested is in the same domain. But it is still the most...
python,google-app-engine,sqlalchemy,importerror,webapp2
On you local machine you have sqlalchemy installed. On appengine you don't have it thats why your import is failing.
html,google-app-engine,python-2.7,google-cloud-storage,webapp2
from __future__ import with_statement import cloudstorage as gcs import webapp2 import logging from google.appengine.ext import blobstore from google.appengine.ext.webapp import blobstore_handlers def CreateFile(filename,imageFile): with gcs.open(filename, 'w', content_type = 'image/jpeg') as f: f.write(imageFile) f.close() blobstore_filename = '/gs' + filename return blobstore.create_gs_key(blobstore_filename) class MyImageHandler(webapp2.RequestHandler): def post(self): bucket='yourbucketname' imageFile = self.request.get('file')...
python,google-app-engine,webapp2
Yes, using their user.email() To access properties of their Google+ profile you will need to use the Google APIs Client Library for Python https://developers.google.com/api-client-library/python/start/installation...
google-app-engine,twitter-bootstrap-3,geolocation,webapp2,geopoints
input_geopoint= GeoPoint(input_latitude, input_longitude) NameError: global name 'GeoPoint' is not defined. Am getting this error You're getting that error because you don't have the module imported where GeoPoint is defined. Add this import from google.appengine.api import search and then use like this input_geopoint = search.GeoPoint(input_latitude, input_longitude) Also see the docs...
python,google-app-engine,webapp2,xlwt
Here's a "hello world" (!) GAE handler trying to do the kind of thing you're talking about: this is main.py, to which app.yaml routes all URLs; I've copied xlwt/*.py into the subdirectory xlwt of the directory in which main.py and app.yaml live. import webapp2 import StringIO import xlwt def makeit():...
python,google-app-engine,webapp2
Memcache instance is global and not tight to the User instance. You add values to memcache by key, so you can implement User bound memcache on your own, by using user key + some additional info as key to memcache value. memcacheService.put(userKey + "userBalance", userBalance); This will cache userBalance per...
python,google-app-engine,webapp2
Use a 307 redirect. A 307 will not change the method of the redirect. Wikipedia: 307 temporary redirect (provides a new URL for the browser to resubmit a GET or POST request)...
python,python-2.7,module,attributes,webapp2
You have a package mymodule, containing a module mymodule. The function is part of the module, not the package. Import the module: import mymodule.mymodule and reference the function on that: mymodule.mymodule.testmod() You can use from ... import and import ... as to influence what gets imported exactly: from mymodule import...
python,json,google-app-engine,python-2.7,webapp2
You are sending in your request a list, not a string events=[{"event":"reset", "test":"reset;123"}] you should use '{"events":[{"event":"reset", "test":"reset;123"}]}' ...
google-app-engine,webapp2,rbac,tipfy
At the end I find out that area can be anything you want and it's up to you what meaning it has. Just define a property in your handler that return some string ... and that's the area. Also ... I Finally end up coding a RBAC for google app...
python,google-app-engine,jinja2,blobstore,webapp2
Your question is missing critical information, how are the routes set up, where's the template code? The problem obviously comes from the client, where else could the request come from? You should be providing information on that front. Anyway, for some weird reason I think I might know what it...
python-2.7,google-app-engine,jinja2,webapp2
The pattern you're trying to write doesn't work within http, irrespective of what backend platform or language you're using. Your HTML is posting to the server and the GAE code is handling the post. At that point in the interaction, the browser has already submitted and is awaiting a response...
python,google-app-engine,webapp2
I've successfully POST'ed a file to GCS with the following method: def post(self): write_retry_params = gcs.RetryParams(backoff_factor=1.1) filename = '/{MY-BUCKET-NAME}/static.txt' gcs_file = gcs.open( filename, 'w', content_type='text/plain', options={'x-goog-meta-foo': 'foo', 'x-goog-meta-bar': 'bar'}, retry_params=write_retry_params) inFile = self.request.POST.multi['file'].file while 1: line = inFile.readline() if not line: break gcs_file.write(line) logging.info('Wrote line: {}'.format(line)) gcs_file.close() Here's the little...
javascript,python,angularjs,google-app-engine,webapp2
Yes, just add it onto the url: $http.get("/users?items=15").success(function(data) { $scope.users = data; }); Then in your python handler for /users get the value of items using self.request.get("items")...
html,css,google-app-engine,twitter-bootstrap,webapp2
For PIL, add this to the libraries section of app.yaml: - name: PIL version: latest To diagnose the 500 error in your css request, try adding this: - url: /static/css static_dir: static/css mime_type = "text/css" (This needs to be ABOVE your - url /static call, so it runs first...
angularjs,entity-framework-6,breeze,webapp2
You need to map the orderId foreign key property of the OrderDetail and DifferentDetail entities. When Breeze sends the entities to the server, it communicates the relationship between entities using the foreign keys.
javascript,backbone.js,webapp2
My problem was that I was defining the url attribute in BOTH the model AND the collection. You should only define url in the collection. Stupid mistake.
Do the work, then redirect to location of the image. # do work self.redirect('/static/image.gif') Alternatively, set the Content-Type to the mime type matching the image, then open the image as a file and write it. A bit more work on the program side, but it saves the extra round trip...
python,python-2.7,python-3.x,webapp2
I dont know webapp2, but 10 is the length of %(status)s. Correct would be val = str(status) as the 1st line, I think. Or simply check for status == XX