【问题标题】:Google App Engine contact formGoogle App Engine 联系表
【发布时间】:2012-12-20 16:11:02
【问题描述】:

我有一个静态 (HTML/CSS) 网站作为 Google App Engine - Python 上的应用程序托管。一切正常,除了我想添加一个联系表。我找到了一个我希望使用的great template,但发现它需要 PHP 才能工作。有没有办法让它工作或找到与 GAE 一起工作的联系表。

我知道将 GAE 用于静态网站并不是它的主要用途,但它是免费的,并且非常适合我想要它做的事情(托管单页简历)。

【问题讨论】:

    标签: python google-app-engine contact-form


    【解决方案1】:

    看看GAE Boilerplate。在样板处理程序中,有一个名为 ContactHandler 的处理程序可以执行您想要执行的操作。

    无论如何你都应该研究一下这个项目的代码,因为它提供了很多用GAE编写代码的好习惯。

    希望这会有所帮助。

    【讨论】:

      【解决方案2】:

      本教程展示了如何通过 webapp2 和 GAE 使用表单。如果您刚刚通过标准 HTTP 提交的版本,您应该能够重新处理它以捕获该信息。

      Handlingforms

      import cgi
      import webapp2
      
      from google.appengine.api import users
      
      class MainPage(webapp2.RequestHandler):
          def get(self):
              self.response.out.write("""
                <html>
                  <body>
                    <form action="/sign" method="post">
                      <div><textarea name="content" rows="3" cols="60"></textarea></div>
                      <div><input type="submit" value="Sign Guestbook"></div>
                    </form>
                  </body>
                </html>""")
      
      
      class Guestbook(webapp2.RequestHandler):
          def post(self):
              self.response.out.write('<html><body>You wrote:<pre>')
              self.response.out.write(cgi.escape(self.request.get('content')))
              self.response.out.write('</pre></body></html>')
      
      app = webapp2.WSGIApplication([('/', MainPage),
                                    ('/sign', Guestbook)],
                                    debug=True)
      

      【讨论】:

      • 感谢您的回复,但我需要它能够将其发送到电子邮件地址(我的)。我想知道某处是否有一个工作示例代码可以做到这一点。会
      • 你应该能够通过一点额外的努力做到这一点。
      • 顺便说一句,您的问题没有提到电子邮件地址。
      猜你喜欢
      • 1970-01-01
      • 2013-09-20
      • 2011-06-19
      • 1970-01-01
      • 1970-01-01
      • 2012-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多