ece2313a2bea4c21193da3d71b9f8c90d671c0e5
# (c) 2017 Aaron Taylor <ataylor at subgeniuskitty dot com>
# See LICENSE file for copyright and license details.
import os
, sys
, subprocess
, cgi
# Accepts a string containing a filesystem path to a text file.
# Returns a string containing the contents of that file.
if debug
.print_to_browser
: print("Unable to open " + path
+ " for reading.")
sys
.exit("Unable to open " + path
+ " for reading.")
# Accepts a string containing markup'ed text
# Returns a string containing HTML'ed text
def process_markup(text
):
p
= subprocess
.Popen(config
.markup_processor
,stdout
=subprocess
.PIPE
,stdin
=subprocess
.PIPE
)
if debug
.print_to_browser
: print("Unable to open markup processor: " + config
.markup_processor
)
sys
.exit("Unable to open markup processor: " + config
.markup_processor
)
text
= p
.communicate(text
.encode('UTF-8'))[0]
return(text
.decode('UTF-8'))
print("Content-Type: text/html;charset=utf-8\n")
text
= load_file(config
.site_path_prefix
+ os
.environ
['REQUEST_URI'] + config
.markup_file_extension
)
print(process_markup(text
))
if __name__
== "__main__":