Blue Flood CDN Refresh API collection is very convenient, but contains clear text account password, public very uncomfortable.
A small station was built in the beginner's python.
Baidu a bit, found that Nginx+uwsgi is currently a good production solution. (Nginx built-in UWSGI module, do not need to recompile)
Half a day to finish, share under convenient later query.
Nginx Related configuration section:
1 Server2 {3Listen the;4 server_name cdn.test.com;5 index index.html;6root/home/webpy;7Location/8 {9 include Uwsgi_params;TenUwsgi_pass127.0.0.1:18888; One } A -access_log/home/wwwlogs/access.log access; -}
To refresh the app code:
1 ImportWeb,urllib2 fromWebImportform3 4 5URLs = ("/.*","Flush")6App =web.application (URLs, Globals ())7application = App.wsgifunc ()#without this paragraph, UWSGI cannot identify the application.8 9Render = Web.template.render ('Templates')Ten One AFlush_form =form. Form ( -Form. Textarea (name='URLs', value="', Rows=20, cols=180), -Form. Button ('Flush', type='Submit') the ) - - classFlush: - + defGET (self): -f =Flush_form () + returnRender.flush (f) A at defPOST (self): -data = Web.data (). Replace ('&flush=',"') -Urllib.urlopen ('http://ccms.chinacache.com/index.jsp?user= user name &pswd= password &ok=ok&' #用户名密码自己加 -+data) - return 'Flush successed. Check back 5 mins later.' - in if __name__=="__main__": -App.run ()
Template page:
$def with (URLs)<H1>Flush CDN</H1><BR/><b>Example</b> Http://p0.test.com/Resource/Images/home/twocode.jpg<BR/><BR/> Http://s0.test.com/Resource/Js/common/jquery-1.8.3.min.js<BR/><BR/><formMethod= "POST">$:urls.render ()</form>
Start Uwsgi:
Need to switch to the directory where the app is located
Uwsgi-s 127.0.0.1:18888-w hellow-p--master-p--max-requests +--uid www--gid www-d/home/wwwlogs/uwsgi.log
Blue Flood CDN Simple Web Refresh Program