Cron2
app.yaml
application: cron2
version: 1
runtime: python
api_version: 1
handlers:
- url: /tasks/.*
script: main.py
cron.yaml
cron:
- description: mailing job
url: /tasks/summary
schedule: every 1 minutes
main.py
#!/usr/bin/env python
import cgi
import wsgiref.handlers
from google.appengine.ext import webapp
from google.appengine.api import mail
#from google.appengine.api import urlfetch
class MailJob(webapp.RequestHandler):
def get(self):
# Call your website using URL Fetch service ...
#url = "http://www.google.com"
#result = urlfetch.fetch(url)
#if result.status_code == 200:
# doSomethingWithResult(result.content)
# Send emails using Mail service ...
#mail.send_mail(sender="barnix2001@gmail.com",
# to="barnix2001@yahoo.com",
# subject="Your account on YourSite.com has expired",
# body="Bla bla bla ...")
mail.send_mail("barnix2001@yahoo.com", "barnix2001@gmail.com", "Google Coder", "Googler Coder Welcome")
return
def main():
application = webapp.WSGIApplication([('/tasks/summary', MailJob)], debug=True)
wsgiref.handlers.CGIHandler().run(application)
#run_wsgi_app(application)
if __name__ == '__main__':
main()