Google webapp to receive feedbacks
This commit is contained in:
parent
d422756ed2
commit
600ad5caf4
9
feedback-ltworf/app.yaml
Normal file
9
feedback-ltworf/app.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
application: feedback-ltworf
|
||||
version: 1
|
||||
runtime: python27
|
||||
api_version: 1
|
||||
threadsafe: true
|
||||
|
||||
handlers:
|
||||
- url: /.*
|
||||
script: feedback.application
|
30
feedback-ltworf/feedback.py
Normal file
30
feedback-ltworf/feedback.py
Normal file
@ -0,0 +1,30 @@
|
||||
from google.appengine.api import users
|
||||
|
||||
import webapp2
|
||||
|
||||
import micro_webapp2
|
||||
application = micro_webapp2.WSGIApplication()
|
||||
|
||||
@application.route('/')
|
||||
def m(request, *args, **kwargs):
|
||||
return ""
|
||||
|
||||
@application.route('/feedback/<id>')
|
||||
def mail_sender(request, *args, **kwargs):
|
||||
|
||||
if request.method != "POST":
|
||||
return ""
|
||||
|
||||
message = ""
|
||||
for k,v in request.POST.iteritems():
|
||||
message += "%s: %s\n" % (k,v)
|
||||
|
||||
if kwargs["id"] == "relational":
|
||||
from google.appengine.api import mail
|
||||
|
||||
mail.send_mail(sender="Feedback service <tiposchi@tiscali.it>",
|
||||
to="tiposchi@tiscali.it",
|
||||
subject="Feedback from %s" % kwargs["id"],
|
||||
body=message)
|
||||
|
||||
return "Message queued"
|
23
feedback-ltworf/micro_webapp2.py
Normal file
23
feedback-ltworf/micro_webapp2.py
Normal file
@ -0,0 +1,23 @@
|
||||
import webapp2
|
||||
|
||||
class WSGIApplication(webapp2.WSGIApplication):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(WSGIApplication, self).__init__(*args, **kwargs)
|
||||
self.router.set_dispatcher(self.__class__.custom_dispatcher)
|
||||
|
||||
@staticmethod
|
||||
def custom_dispatcher(router, request, response):
|
||||
rv = router.default_dispatcher(request, response)
|
||||
if isinstance(rv, basestring):
|
||||
rv = webapp2.Response(rv)
|
||||
elif isinstance(rv, tuple):
|
||||
rv = webapp2.Response(*rv)
|
||||
|
||||
return rv
|
||||
|
||||
def route(self, *args, **kwargs):
|
||||
def wrapper(func):
|
||||
self.router.add(webapp2.Route(handler=func, *args, **kwargs))
|
||||
return func
|
||||
|
||||
return wrapper
|
Loading…
Reference in New Issue
Block a user