diff --git a/main.py b/main.py index 51f3a21..1637ff8 100755 --- a/main.py +++ b/main.py @@ -1,7 +1,6 @@ import bottle request = bottle.request response = bottle.response -redirect = bottle.redirect import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart @@ -17,11 +16,6 @@ import datetime # to name unsent mails ##################################################### Bottle stuff ############################################ -# The exception that is thrown when an argument is missing -class MissingParameterException (Exception): - pass - - class StripPathMiddleware(object): ''' Get that slash out of the request @@ -37,6 +31,11 @@ app = application = bottle.Bottle(catchall=False) ##################################################### Configuration ############################################ + +# The exception that is thrown when an argument is missing +class MissingParameterException (Exception): + pass + def get_env(var, default=None): """var is an env var name, default is the value to return if var does not exist. If no default and no value, an exception is raised.""" if var in os.environ: @@ -92,13 +91,14 @@ mongodb_database = mongodb_client[mongodb_dbname] @app.post('/submit') def submission (): - # Getting subject + # Getting token if 'token' in request.forms: token = request.forms.getunicode('token') else: response.status = 400 return 'Le jeton d’autentification est requis' + # Getting mail address if 'mail' in request.forms: from_address = request.forms.getunicode('mail') else: @@ -145,7 +145,7 @@ def submission (): # Redirection - #redirect(success_redirect_default) + #bottle.redirect(success_redirect_default) origin = request.headers.get('origin') return '
Mail envoyé !
' + ('Retour au formulaire de contact
'.format(origin) if origin else '')