I'm banging my head against the wall with this appengine application. Tried the remedies given for similar questions to no avail. Maybe someone can spot what the issue is?
Here's what I'm doing:
1) I create a product in the app based on the user's input. Once written to the ndb I call a page to display the recently created product:
import requests
....
r = requests.post('products_display', data = {'find_id_txt':prod_id_txt})
The request is routed through:
application = webapp2.WSGIApplication([
('/products_add', AddProduct),
('/products_display', DisplayProduct),
...
], config = session_params, debug = True)
It then arrives at the correct handler and I get the 405 error (405 Method Not Allowed The method GET is not allowed for this resource). The browser shows this url:
http://localhost:8080/products_display
This is the code of the handler (for the moment I just display a page to tell if the product was found or not).
class DisplayProduct(BaseHandler):
# Finds a product on exact Prod_ID property
def get(self):
user = usermgmt.get_user(self)
logout_url = users.create_logout_url(self.request.uri)
access = usermgmt.get_auth("Products")
client_name = usermgmt.get_client_subdomain()
search_key = self.request.get('find_id_txt')
find_query = models.Product.query(models.Product.prod_id == search_key, ancestor = get_products_key()).get()
# Check if query returned a value
if find_query:
template_values = {
'client_name': client_name,
'user': user,
'logout_url': logout_url,
'alert_message': "Product1: " + search_key + " was found."
}
template = JINJA_ENVIRONMENT.get_template('alert-blue.html')
self.response.write(template.render(template_values))
else:
template_values = {
'client_name': client_name,
'user': user,
'logout_url': logout_url,
'alert_message': "Product1: " + search_key + " could not be found."
}
template = JINJA_ENVIRONMENT.get_template('alert-yellow.html')
self.response.write(template.render(template_values))
I tried all possible combinations of sending a get, then a post request and changing get for post on the handler. Each time I logged out of the browser or use another one and still I get the error.
The code is written susing pydev on eclipse neon on Linux Ubuntu 16.04. Once it's debugged I can upload it to Google's cloud.
Thanks in advance for any tips!
Try this to troubleshoot:
import logging
class DisplayProduct(BaseHandler):
def get:
logging.info("this is a GET")
def post:
logging.info("this is a POST")
Then, send your current POST. Next, send a request to: http://localhost:8080/products_display?find_id_txt=test
. Hopefully, you'll see what is happening.
Firebase Cloud Functions: PubSub, "res.on is not a function"
TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
I'm trying to interface with a program (GoGui - https://sourceforgenet/projects/gogui/) using the Go Text Protocol (GTP - http://www
The following Python code snippet illustrates the issue: