页面功能:
相关的后端代码:
- #!/usr/bin/evn python
- #coding=utf-8
- __author__ = '戴儒锋'
- import json
- from bottle import get,post
- from bottle import template
- from controller.core import reMsg,checkArgs
- #导入阿里云API和阿里云KEY、SECRET
- import aliyun.api
- from conf import setting
- ali_key = setting.ali_key
- ali_secret = setting.ali_secret
- aliyun.setDefaultAppInfo(ali_key,ali_secret)
- @get('/cdn/')
- def callback():
- return template('cdn')
- @post('/get_domains/')
- def callback():
- #获取域名列表
- a = aliyun.api.Cdn20141111DescribeUserDomainsRequest()
- f = a.getResponse()
- data = f.get('Domains').get('PageData')
- return json.dumps(data)
- @post('/refresh_cdn/')
- def callback():
- """刷新CDN"""
- url_path = checkArgs('url_path',"文件URL路径")
- s_type = checkArgs('s_type',"文件类型")
- msg_list = []
- for url in url_path.split():
- a = aliyun.api.Cdn20141111RefreshObjectCachesRequest()
- a.ObjectPath = url
- a.ObjectType = s_type
- try:
- f = a.getResponse()
- msg_list.append(f)
- except Exception,e:
- msg_list.append({"url":url,"status":"faild"})
- print msg_list
- return reMsg(0,"刷新完成,稍等会即生效")
- @post('/refresh_history_cdn/')
- def callback():
- """选择文件刷新CDN"""
- url_path = checkArgs('url_path',"文件URL路径")
- a = aliyun.api.Cdn20141111RefreshObjectCachesRequest()
- a.ObjectPath = url_path
- a.ObjectType = "File"
- try:
- f = a.getResponse()
- print f
- except Exception,e:
- print e
- return reMsg(0,"刷新完成,稍等会即生效")
2016 年 2 月 24 日 上午 11:17 板凳
撒旦撒旦
2018 年 8 月 1 日 下午 3:52 1层
@sss 好厉害–看看——~~
2016 年 1 月 22 日 上午 11:01 沙发
我的是直接用rsync 捕获close_write 事件,然后用python调用阿里云cdn的purge接口
2016 年 1 月 22 日 下午 2:59 1层
@ping 嗯,分享下
2016 年 2 月 24 日 上午 11:18 1层
@ping 分享一下哇