我的音悦台——音乐可视化的Python实现
- cd /mnt/sda2/web.py-0.33/
- python setup.py install
继音乐可视化的WEB实现之后,我继续研究基于Python的webpy实现
有关Python的web开发——简单开发环境的搭建(复杂的我也不会);
1、安装Python,路由器的话简单下载插件本地安装就行了,树莓派等一些Linux平台一般都是自带的无需手动安装,目前使用最多的还是2.7版本兼容性比较好;
2、下载web.py-0.33,解压到挂载到系统的优盘根目录,随便在哪,只要你能找到就行,比如我的路径是/mnt/sda2/web.py-0.33/
3、安装web.py
4、上述步骤就已经完成安装了,下面简单写一个music.py
#! /usr/bin/env python
# -*- coding:utf-8 -*-
import web
import os
#import model
urls = (
'/', 'index',
)
app = web.application(urls, globals())
render = web.template.render('templates/')
class index:
def GET(self):
fdir = "static/media"
for root, dirs, files in os.walk(fdir):
files = sorted(files)
return render.index(files)
def notfound():
return web.notfound("Sorry, the page you were looking for was not found.")
app.notfound = notfound
if __name__ == '__main__':
app.run()
6、运行music.py之后,浏览器就可以看到效果了,完全跟PHP一样的效果:
- cd /mnt /sda2/app/music #根据你自己的目录
- python music.py #运行程序启动本地服务器
- 127.0.0.1:8080 #浏览器打开网页
7、关于webpy的简单介绍,简单的框架图,具体的话有兴趣的童鞋可以Google一下:





还没有人抢沙发呢~