leaving_traces leaving_traces - 1 year ago 118
Python Question

Flask to return nothing but only run script

To send email every day at 19:00 using Flask framework in Google app engine.

My program works just perfect, but my app intentionally generate

View function did not return a response

this error.

Here is my code below.



- url: /sendemail
script: send_email.app
login: admin



- description: Send Email
url: /sendemail
schedule: every day 19:00



@app.route('/sendemail', methods=('GET', 'POST'))
def sendemail():
toaddr = "email@email.com"
body = "MYBODY"
to_email = mail.Email(toaddr)
from_email = mail.Email(SENDGRID_SENDER)
content = mail.Content('text/html', body)
subject = "SUBJECT"
message = mail.Mail(from_email, subject, to_email, content)

as you can see above in send_email.py, It doesn't return anything so my application return an error, but sending an email works just perfect.

So How can I achieve sending email without giving an error?

I am pretty new to Flask and web programming so I want to achieve this goal with only Flask (not Webapp2).

Thanks in advance.

Answer Source

Add this as a return statement for your sendemail function

return ('', 204)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download