History

added aubioweb added aubioweb

Paul Brossier committed 20 years ago

Commit 51402761 parent 660c1d84 files · +567 −0Browse files

Showing the changes to python/aubioweb.py (1 of 4 files). Show all

Unified · Split

python/aubioweb.py+113−0
@@ -0,0 +1,113 @@
1+#!/usr/bin/python
2+
3+doc = """
4+This script works with mod_python to browse a collection of annotated wav files
5+and results.
6+
7+you will need to have at least the following packages need to be installed (the
8+name of the command line tool is precised in parenthesis):
9+
10+libapache-mod-python (apache2 prefered)
11+sndfile-programs (sndfile-info)
12+vorbis-tools (oggenc)
13+python-gnuplot
14+python-numarray
15+
16+Try the command line tools in aubio/python to test your installation.
17+
18+NOTE: this script is probably horribly insecure.
19+
20+example configuration for apache to put in your preferred virtual host.
21+
22+<Directory /home/piem/public_html/aubioweb>
23+ # Minimal config
24+ AddHandler mod_python .py
25+ # Disable these in production
26+ PythonDebug On
27+ PythonAutoReload on
28+ # Default handler in url
29+ PythonHandler aubioweb
30+ ## Authentication stuff (optional)
31+ #PythonAuthenHandler aubioweb
32+ #AuthType Basic
33+ #AuthName "Restricted Area"
34+ #require valid-user
35+ # make default listing
36+ DirectoryIndex aubioweb/
37+</Directory>
38+
39+"""
40+
41+from aubio.web.html import *
42+
43+def handler(req):
44+ from aubio.web.browser import *
45+ from mod_python import Session
46+ req.sess = Session.Session(req)
47+ req.sess['login']='new aubio user'
48+ req.sess.save()
49+ return configure_handler(req,index)
50+
51+def index(req,threshold='0.3'):
52+ navigation(req)
53+ print_command(req,"sfinfo %%i")
54+ return footer(req)
55+
56+def show_info(req,verbose=''):
57+ navigation(req)
58+ print_command(req,"sndfile-info %%i")
59+ return footer(req)
60+
61+def feedback(req):
62+ navigation(req)
63+ req.write("""
64+ Please provide feedback below:
65+ <p>
66+ <form action="/~piem/aubioweb/email" method="POST">
67+ Name: <input type="text" name="name"><br>
68+ Email: <input type="text" name="email"><br>
69+ Comment: <textarea name="comment" rows=4 cols=20></textarea><br>
70+ <input type="submit">
71+ </form>
72+ """)
73+
74+WEBMASTER='piem@calabaza'
75+SMTP_SERVER='localhost'
76+
77+def email(req,name,email,comment):
78+ import smtplib
79+ # make sure the user provided all the parameters
80+ if not (name and email and comment):
81+ return "A required parameter is missing, \
82+ please go back and correct the error"
83+ # create the message text
84+ msg = """\
85+From: %s
86+Subject: feedback
87+To: %s
88+
89+I have the following comment:
90+
91+%s
92+
93+Thank You,
94+
95+%s
96+
97+""" % (email, WEBMASTER, comment, name)
98+ # send it out
99+ conn = smtplib.SMTP(SMTP_SERVER)
100+ try:
101+ conn.sendmail(email, [WEBMASTER], msg)
102+ except smtplib.SMTPSenderRefused:
103+ return """<html>please provide a valid email</html>"""
104+
105+ conn.quit()
106+ # provide feedback to the user
107+ s = """\
108+<html>
109+Dear %s,<br>
110+Thank You for your kind comments, we
111+will get back to you shortly.
112+</html>""" % name
113+ return s

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t