2016-08-29 11 views
0

Python 2.7のGoogleアプリエンジンをインストールしましたが、テスト用のコードをいくつか書きました。単なるHTMLフォームです。ここでは、コードは次のようになります。GoogleアプリケーションエンジンHTTPエラー500

import webapp2 

form = """ 
<form method="post"> 
    What is your birthday? 
    <br> 
    <label> Month 
     <input type="text" name="month"> 
    </label> 

    <label> Day 
     <input type="text" name="day"> 
    </label> 

    <label> Year 
     <input type="text" name="year"> 
    </label> 

    <br> 
    <br> 
    <input type="submit"> 
</form> 
""" 

class MainPage(webapp2.RequestHandler): 
    def get(self): 
     self.response.out.write(form) 

    def post(self): 
     self.response.out.write("Succes!") 

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

そして、私はそうのように私のフォームを書き出し、別の手順を、書き込もうとしました:

import webapp2 

form = """ 
<form method="post"> 
    What is your birthday? 
    <br> 
    <label> Month 
     <input type="text" name="month"> 
    </label> 

    <label> Day 
     <input type="text" name="day"> 
    </label> 

    <label> Year 
     <input type="text" name="year"> 
    </label> 

    <br> 
    <br> 
    <input type="submit"> 
</form> 
""" 

class MainPage(webapp2.RequestHandler): 
    def write_form(self): 
     self.response.out.write(form) 

    def get(self): 
     self.write_form() 

    def post(self): 
     self.response.out.write("Succes!") 

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

まあ、事は、最初のコードが正常に動作しているということですもう1つはHTTPエラー500を返しています。私はUdacityのコースからこれを試してみましたが、そこからコードをコピーしました。なぜそれが動作していないのか分かりません。

PS。 "IndentationError:インデントが外側インデントレベルと一致しない INFO 2016-08-29 12:17:37,155 module.py:788]デフォルト:" GET/HTTP/1.1 "500 - "

後で編集:私は、単に" write_form "プロシージャをMainPageクラス内の" get "プロシージャの後に記述することでこれを解決しました。

答えて

関連する問題