码迷,mamicode.com
首页 > Web开发 > 详细

蓝汛cdn简易web刷新程序

时间:2014-10-22 20:05:56      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   os   ar   for   sp   

蓝汛cdn刷新api收藏来着用很方便,不过包含明文帐号密码,公用非常不爽.

遂在初学的python建了个小站.

百度了一下,发现nginx+uwsgi是目前不错的生产解决方案.(nginx内置了uwsgi模块,用不着重新编译)

半天弄完,分享下方便以后查询.

nginx相关配置段:

 1 server
 2         {
 3                 listen       80;
 4                 server_name cdn.test.com;
 5                 index index.html;
 6                 root  /home/webpy;
 7                 location /
 8                         {
 9                                 include uwsgi_params;
10                                 uwsgi_pass 127.0.0.1:18888;
11                         }
12 
13                 access_log  /home/wwwlogs/access.log  access;
14 }

刷新app代码:

 1 import web,urllib
 2 from web import form
 3 
 4 
 5 urls = ("/.*", "flush")
 6 app = web.application(urls, globals())
 7 application = app.wsgifunc() #不加这段,uwsgi无法识别应用.
 8 
 9 render = web.template.render(templates)
10 
11 
12 flush_form = form.Form(
13     form.Textarea(name=urls, value=‘‘, rows=20, cols=180),
14     form.Button(Flush, type=submit)
15     )
16 
17 class flush:
18 
19     def GET(self):
20         f = flush_form()
21         return render.flush(f)
22 
23     def POST(self):
24         data = web.data().replace(&Flush=, ‘‘)
25         urllib.urlopen(http://ccms.chinacache.com/index.jsp?user=用户名&pswd=密码&ok=ok&‘ #用户名密码自己加
26                        + data)
27         return Flush successed.Check back 5 mins later.
28 
29 if __name__ == "__main__":
30     app.run()

模板页:

$def with(urls)


<h1>Flush CDN</h1><br />
<b>example:</b>&nbsp;http://p0.test.com/Resource/Images/home/twocode.jpg<br /><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http://s0.test.com/Resource/Js/common/jquery-1.8.3.min.js<br /><br />
<form method="POST">
    $:urls.render()
</form>

启动uwsgi:

需要切换到app所在目录

uwsgi -s 127.0.0.1:18888 -w hellow -p --master -p 10 --max-requests 1000 --uid www --gid www -d /home/wwwlogs/uwsgi.log

 

蓝汛cdn简易web刷新程序

标签:style   blog   http   color   io   os   ar   for   sp   

原文地址:http://www.cnblogs.com/zillaer/p/4043938.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!