serve.py
1 |
import logging |
---|---|
2 |
from livereload import Server, shell |
3 |
|
4 |
'''This script runs a webserver that monitors files for changes and sends
|
5 |
update notification to the browser. To run, cd to the directory the script
|
6 |
is located and:
|
7 |
|
8 |
python serve.py
|
9 |
|
10 |
'''
|
11 |
|
12 |
logging.basicConfig(level=logging.DEBUG) |
13 |
|
14 |
params = {'xsl' : 'xsl/onedcx/onedcx.xsl', |
15 |
'xml' : 'examples/test2.xml', |
16 |
'pid' : 'cmd_line_PID_value', |
17 |
'docid': 'metacat_doc_id', |
18 |
'qformat': 'view_type', |
19 |
'contextURL': 'http://localhost:5500', |
20 |
} |
21 |
cmd = """xsltproc --xincludestyle --stringparam pid "{pid}" \
|
22 |
--stringparam qformat "{qformat}" \
|
23 |
--stringparam docid "{docid}" \
|
24 |
--stringparam contextURL "{contextURL}" \
|
25 |
{xsl} {xml}""".format(**params)
|
26 |
|
27 |
server = Server() |
28 |
print "Running with command: {0}".format(cmd) |
29 |
server.watch(params['xsl'], shell(cmd, output='test2.html', cwd='.')) |
30 |
server.watch(params['xml'], shell(cmd, output='test2.html', cwd='.')) |
31 |
server.serve(root=".", open_url=False) |
32 |
|