蓝汛cdn简易web刷新程序

蓝汛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

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。