11.8笔记python webpy优雅的设置静态文件路径,macos防止休眠

webpy如果要访问静态文件,路径总是要加/static/,如果把别人的demo移植到自己的项目,那么就要改好多东西,甚至连部分js里面写好的路径都要修改,总感觉这是很愚蠢的行为,于是在网上找到这篇文章:
http://blog.csdn.net/trbbadboy/article/details/8207328
访问.ioc时把链接重定向,在这里,我做的是它的补充:

urls = (
    '([a-z0-9\/]*)', 'dealRequest',
    '(.*\..{1,3})','StaticFile',#后缀1到3个字母的文件
    )

class StaticFile:
    def GET(self, file):
        print file
        web.seeother('/static/'+file); #重定向

这样一来,访问所有的包含后缀名的文件都会在static里面取,所以下次移植别人的demo的时候便而已直接吧文件拷贝到static里面就好了,也不用改代码里面的路径了。

macos如何防止休眠?

pmset noidle

control+c结束后变恢复正常

关于pmset修改休眠模式的命令介绍:
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/pmset.1.html
http://bbs.pcbeta.com/viewthread-1126476-1-1.html

请访问我的博客浏览更多文章:http://blog.csdn.net/u010499721

你可能感兴趣的:(python)