用于删除IP表的信息.
希望对你有所帮助.
注意点:
1.cron.yaml与app.yaml都需要定义处理的url:
/cron/deleteips
app.yaml上的定义是真实处理的url
cron.yaml上的是指向的url.用于appengine的服务器识别
2.处理的地址上的工作必须能在限定的时间内完成(约9秒)
cron.yaml:
cron:
- description: ip delete job
url: /cron/deleteips
schedule: every 1 minutes
app.yaml:
application: ip13800
version: 1
runtime: python
api_version: 1
handlers:
- url: /cron/deleteips
script: cron/cron.py
cron/cron.py:
#encoding=GBK
import wsgiref.handlers
import os, re
from urllib import unquote, urlencode
from datetime import datetime
from google.appengine.ext import webapp
from google.appengine.ext import db
from index import *
class MainPage(webapp.RequestHandler):
def get(self):
if Queries().all().count() == 1000:
query = Queries().all()
results = query.fetch(100);
db.delete(results)
self.response.out.write("ok removed")
def post(self):
self.response.out.write("ok")
def main():
application = webapp.WSGIApplication(
[
('/cron/deleteips', MainPage)
],
debug=True)
wsgiref.handlers.CGIHandler().run(application)
if __name__ == "__main__":
main()