source: python/aubioweb.py @ f647e82

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since f647e82 was 5140276, checked in by Paul Brossier <piem@altern.org>, 19 years ago

added aubioweb
added aubioweb

  • Property mode set to 100644
File size: 2.8 KB
Line 
1#!/usr/bin/python
2
3doc = """
4This script works with mod_python to browse a collection of annotated wav files
5and results.
6
7you will need to have at least the following packages need to be installed (the
8name of the command line tool is precised in parenthesis):
9
10libapache-mod-python (apache2 prefered)
11sndfile-programs (sndfile-info)
12vorbis-tools (oggenc)
13python-gnuplot
14python-numarray
15
16Try the command line tools in aubio/python to test your installation.
17
18NOTE: this script is probably horribly insecure.
19
20example 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
41from aubio.web.html import *
42
43def 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
51def index(req,threshold='0.3'):
52    navigation(req)
53    print_command(req,"sfinfo %%i")
54    return footer(req)
55
56def show_info(req,verbose=''):
57    navigation(req)
58    print_command(req,"sndfile-info %%i")
59    return footer(req)
60
61def 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
74WEBMASTER='piem@calabaza'
75SMTP_SERVER='localhost'
76
77def 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 = """\
85From: %s                                                                                                                                           
86Subject: feedback
87To: %s
88
89I have the following comment:
90
91%s
92
93Thank 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>
109Dear %s,<br>
110Thank You for your kind comments, we
111will get back to you shortly.
112</html>""" % name
113    return s
Note: See TracBrowser for help on using the repository browser.