Child: [dd5296] (diff)

Download this file

uprclcontrol.py    58 lines (46 with data), 1.9 kB

 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Copyright (C) 2017 J.F.Dockes
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
from __future__ import print_function
import os
from bottle import route, run, template
from bottle import static_file
from uprclutils import uplog
import uprclinit
# Note that we start a separate server. There might be a way to serve
# both the audio files and the control app from the same server...
def runbottle(host='0.0.0.0', port=9278):
global datadir
datadir = os.path.dirname(__file__)
datadir = os.path.join(datadir, 'bottle')
run(host=host, port=port)
@route('/')
def main(name='namesample'):
return template('<b>MAIN PAGE for {{name}}</b>!', name=name)
@route('/update')
def main(name='namesample'):
# Can't use import directly because of the minus sign.
uplog("Calling start_update")
uprclinit.start_update()
uplog("start_update returned")
return template('<b>Index update started {{name}}</b>!', name='')
@route('/static/<filepath:path>')
def server_static(filepath):
uplog("control: server_static: filepath %s datadir %s" % (filepath,datadir))
return static_file(filepath, root=os.path.join(datadir, 'static'))
@route('/hello/<name>')
def index(name):
return template('<b>Hello {{name}}</b>!', name=name)