-
Notifications
You must be signed in to change notification settings - Fork 85
/
web_server.py
41 lines (38 loc) · 990 Bytes
/
web_server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
#coding=utf-8
import web
import logging
from fmpi import FMPI
from threading import Thread
urls = (
'/',"INDEX",
)
app = web.application(urls,globals())
web.config.debug = False
pi = FMPI()
class INDEX(FMPI):
'''web页面相关'''
def index(self):
html = '''<head>
<meta charset="UTF-8">
<link rel="shortcut icon" href="/static/favicon.ico" >
</head>
<html>
<form action="/" method="GET">
music path or url:
<input type="TEXT" name="m" />
<input type="submit" value="play" />
</from>
</html>
'''
return html
def GET(self,args=None):
input = web.input()
if input.has_key('m'):
key = input['m']
logging.info("play %s"%key)
pi.play(key)
return self.index()
if __name__=='__main__':
logging.basicConfig(level=logging.INFO,format="%(message)s")
app.run() #web服务器--主线程