Google App Engine Python using POST method in MainPage












2















I am trying to understand an issue with Google App Engine and Python. It appears that I cannot have a POST handler in the MainPage class. Or, I am somehow using it incorrectly. The system does not object to the Python code but does not seem to find the post method. The response from the server is "405 Method Not Allowed" and "The method POST is not allowed for this resource. "



The output on the dev_appserver.py console is



INFO 2018-11-14 13:41:32,104 module.py:861] default: "GET / HTTP/1.1" 200 267



INFO 2018-11-14 13:41:35,550 module.py:861] default: "POST / HTTP/1.1" 405 188



The original source is



# -*- coding: utf-8 -*-
import webapp2
import logging

form = """
<form action="/" method="post">
<input type="checkbox" name="vehicle" value="Bike">Bike<br>
<input type="checkbox" name="vehicle" value="Car">Car<br>
<input type="submit" value="Submit" >
</form>
"""

class MainPage(webapp2.RequestHandler):
def get(self):
self.response.write(form) # write the blank form

def post(self):
logging.info("in MainPage>post")
self.response.write("Thanks! That works !!!")

app = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)


The GET method is invoked correctly and the simple form is displayed properly. The 405 error appears when I make a selection and submit the form. I have declared the form with both;



<form  action="/" method="post">


and



<form  method="post">


I can create an additional class that can contains a POST method and have action select the other class; everything works fine. I just have not found any logical reason it cannot correctly function in MainPage.



Thanks for your help.










share|improve this question

























  • Try <form action="" method="post">

    – GAEfan
    Nov 14 '18 at 16:55











  • No difference. <form action="" ...> still generates a "405 Method Not Allowed"

    – js98
    Nov 14 '18 at 19:39











  • Check the source code in the browser. You may have the old action="" cached. Restart your dev machine.

    – GAEfan
    Nov 14 '18 at 22:51











  • I have flushed the buffers. I have even switched machines. No change. So far POST only operates in a handler class other than MainPage. But NOT when the POST method is implemented in the MainPage class.

    – js98
    Nov 15 '18 at 14:13











  • show the source code in the browser. (view source)

    – GAEfan
    Nov 15 '18 at 18:06
















2















I am trying to understand an issue with Google App Engine and Python. It appears that I cannot have a POST handler in the MainPage class. Or, I am somehow using it incorrectly. The system does not object to the Python code but does not seem to find the post method. The response from the server is "405 Method Not Allowed" and "The method POST is not allowed for this resource. "



The output on the dev_appserver.py console is



INFO 2018-11-14 13:41:32,104 module.py:861] default: "GET / HTTP/1.1" 200 267



INFO 2018-11-14 13:41:35,550 module.py:861] default: "POST / HTTP/1.1" 405 188



The original source is



# -*- coding: utf-8 -*-
import webapp2
import logging

form = """
<form action="/" method="post">
<input type="checkbox" name="vehicle" value="Bike">Bike<br>
<input type="checkbox" name="vehicle" value="Car">Car<br>
<input type="submit" value="Submit" >
</form>
"""

class MainPage(webapp2.RequestHandler):
def get(self):
self.response.write(form) # write the blank form

def post(self):
logging.info("in MainPage>post")
self.response.write("Thanks! That works !!!")

app = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)


The GET method is invoked correctly and the simple form is displayed properly. The 405 error appears when I make a selection and submit the form. I have declared the form with both;



<form  action="/" method="post">


and



<form  method="post">


I can create an additional class that can contains a POST method and have action select the other class; everything works fine. I just have not found any logical reason it cannot correctly function in MainPage.



Thanks for your help.










share|improve this question

























  • Try <form action="" method="post">

    – GAEfan
    Nov 14 '18 at 16:55











  • No difference. <form action="" ...> still generates a "405 Method Not Allowed"

    – js98
    Nov 14 '18 at 19:39











  • Check the source code in the browser. You may have the old action="" cached. Restart your dev machine.

    – GAEfan
    Nov 14 '18 at 22:51











  • I have flushed the buffers. I have even switched machines. No change. So far POST only operates in a handler class other than MainPage. But NOT when the POST method is implemented in the MainPage class.

    – js98
    Nov 15 '18 at 14:13











  • show the source code in the browser. (view source)

    – GAEfan
    Nov 15 '18 at 18:06














2












2








2








I am trying to understand an issue with Google App Engine and Python. It appears that I cannot have a POST handler in the MainPage class. Or, I am somehow using it incorrectly. The system does not object to the Python code but does not seem to find the post method. The response from the server is "405 Method Not Allowed" and "The method POST is not allowed for this resource. "



The output on the dev_appserver.py console is



INFO 2018-11-14 13:41:32,104 module.py:861] default: "GET / HTTP/1.1" 200 267



INFO 2018-11-14 13:41:35,550 module.py:861] default: "POST / HTTP/1.1" 405 188



The original source is



# -*- coding: utf-8 -*-
import webapp2
import logging

form = """
<form action="/" method="post">
<input type="checkbox" name="vehicle" value="Bike">Bike<br>
<input type="checkbox" name="vehicle" value="Car">Car<br>
<input type="submit" value="Submit" >
</form>
"""

class MainPage(webapp2.RequestHandler):
def get(self):
self.response.write(form) # write the blank form

def post(self):
logging.info("in MainPage>post")
self.response.write("Thanks! That works !!!")

app = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)


The GET method is invoked correctly and the simple form is displayed properly. The 405 error appears when I make a selection and submit the form. I have declared the form with both;



<form  action="/" method="post">


and



<form  method="post">


I can create an additional class that can contains a POST method and have action select the other class; everything works fine. I just have not found any logical reason it cannot correctly function in MainPage.



Thanks for your help.










share|improve this question
















I am trying to understand an issue with Google App Engine and Python. It appears that I cannot have a POST handler in the MainPage class. Or, I am somehow using it incorrectly. The system does not object to the Python code but does not seem to find the post method. The response from the server is "405 Method Not Allowed" and "The method POST is not allowed for this resource. "



The output on the dev_appserver.py console is



INFO 2018-11-14 13:41:32,104 module.py:861] default: "GET / HTTP/1.1" 200 267



INFO 2018-11-14 13:41:35,550 module.py:861] default: "POST / HTTP/1.1" 405 188



The original source is



# -*- coding: utf-8 -*-
import webapp2
import logging

form = """
<form action="/" method="post">
<input type="checkbox" name="vehicle" value="Bike">Bike<br>
<input type="checkbox" name="vehicle" value="Car">Car<br>
<input type="submit" value="Submit" >
</form>
"""

class MainPage(webapp2.RequestHandler):
def get(self):
self.response.write(form) # write the blank form

def post(self):
logging.info("in MainPage>post")
self.response.write("Thanks! That works !!!")

app = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)


The GET method is invoked correctly and the simple form is displayed properly. The 405 error appears when I make a selection and submit the form. I have declared the form with both;



<form  action="/" method="post">


and



<form  method="post">


I can create an additional class that can contains a POST method and have action select the other class; everything works fine. I just have not found any logical reason it cannot correctly function in MainPage.



Thanks for your help.







python-2.7 google-app-engine webapp2






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 21:47







js98

















asked Nov 14 '18 at 14:20









js98js98

162




162













  • Try <form action="" method="post">

    – GAEfan
    Nov 14 '18 at 16:55











  • No difference. <form action="" ...> still generates a "405 Method Not Allowed"

    – js98
    Nov 14 '18 at 19:39











  • Check the source code in the browser. You may have the old action="" cached. Restart your dev machine.

    – GAEfan
    Nov 14 '18 at 22:51











  • I have flushed the buffers. I have even switched machines. No change. So far POST only operates in a handler class other than MainPage. But NOT when the POST method is implemented in the MainPage class.

    – js98
    Nov 15 '18 at 14:13











  • show the source code in the browser. (view source)

    – GAEfan
    Nov 15 '18 at 18:06



















  • Try <form action="" method="post">

    – GAEfan
    Nov 14 '18 at 16:55











  • No difference. <form action="" ...> still generates a "405 Method Not Allowed"

    – js98
    Nov 14 '18 at 19:39











  • Check the source code in the browser. You may have the old action="" cached. Restart your dev machine.

    – GAEfan
    Nov 14 '18 at 22:51











  • I have flushed the buffers. I have even switched machines. No change. So far POST only operates in a handler class other than MainPage. But NOT when the POST method is implemented in the MainPage class.

    – js98
    Nov 15 '18 at 14:13











  • show the source code in the browser. (view source)

    – GAEfan
    Nov 15 '18 at 18:06

















Try <form action="" method="post">

– GAEfan
Nov 14 '18 at 16:55





Try <form action="" method="post">

– GAEfan
Nov 14 '18 at 16:55













No difference. <form action="" ...> still generates a "405 Method Not Allowed"

– js98
Nov 14 '18 at 19:39





No difference. <form action="" ...> still generates a "405 Method Not Allowed"

– js98
Nov 14 '18 at 19:39













Check the source code in the browser. You may have the old action="" cached. Restart your dev machine.

– GAEfan
Nov 14 '18 at 22:51





Check the source code in the browser. You may have the old action="" cached. Restart your dev machine.

– GAEfan
Nov 14 '18 at 22:51













I have flushed the buffers. I have even switched machines. No change. So far POST only operates in a handler class other than MainPage. But NOT when the POST method is implemented in the MainPage class.

– js98
Nov 15 '18 at 14:13





I have flushed the buffers. I have even switched machines. No change. So far POST only operates in a handler class other than MainPage. But NOT when the POST method is implemented in the MainPage class.

– js98
Nov 15 '18 at 14:13













show the source code in the browser. (view source)

– GAEfan
Nov 15 '18 at 18:06





show the source code in the browser. (view source)

– GAEfan
Nov 15 '18 at 18:06












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53302369%2fgoogle-app-engine-python-using-post-method-in-mainpage%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53302369%2fgoogle-app-engine-python-using-post-method-in-mainpage%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Lugert, Oklahoma