2019-05-28 20:00:09 +02:00
|
|
|
import bottle
|
|
|
|
import os.path
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
HOST = "0.0.0.0"
|
2019-07-04 22:33:27 +02:00
|
|
|
PORT = 8000
|
2019-05-28 20:00:09 +02:00
|
|
|
|
|
|
|
# this script runs a small webserver on HOST:PORT that return the class course
|
|
|
|
# all assets are stored in ./resources and available for download
|
|
|
|
# the main page can be visited by going to "http://HOST:PORT/puredata"
|
|
|
|
# the bottle framework is needed to run this script
|
|
|
|
# you can install it with "python3 -m pip install --user bottle"
|
|
|
|
|
2019-07-04 22:33:27 +02:00
|
|
|
@bottle.route("/")
|
|
|
|
def index():
|
|
|
|
return bottle.static_file("language.html", root="./")
|
|
|
|
|
|
|
|
@bottle.route("/en")
|
|
|
|
def index():
|
|
|
|
return bottle.static_file("index_en.html", root="./")
|
|
|
|
|
|
|
|
@bottle.route("/fr")
|
|
|
|
def index():
|
|
|
|
return bottle.static_file("index_fr.html", root="./")
|
|
|
|
|
2019-05-28 20:00:09 +02:00
|
|
|
@bottle.route("/<filename>")
|
|
|
|
def index(filename):
|
|
|
|
if filename == "puredata":
|
|
|
|
return bottle.static_file("index.html", root="./")
|
|
|
|
else:
|
|
|
|
return bottle.static_file(filename, root="./")
|
|
|
|
|
2019-07-04 22:33:27 +02:00
|
|
|
@bottle.route("/screenshots/<filename>")
|
|
|
|
def resources(filename):
|
|
|
|
return bottle.static_file(filename, root="screenshots")
|
|
|
|
|
|
|
|
|
2019-05-28 20:00:09 +02:00
|
|
|
@bottle.route("/resources/<filename>")
|
|
|
|
def resources(filename):
|
|
|
|
return bottle.static_file(filename, root="resources")
|
|
|
|
|
|
|
|
def main():
|
2019-07-04 22:39:56 +02:00
|
|
|
print("pulling latest github push")
|
|
|
|
status = subprocess.call(["git", "pull", "origin"])
|
|
|
|
if status is not 0:
|
|
|
|
print("error pulling froom github...")
|
|
|
|
exit()
|
2019-07-04 22:33:27 +02:00
|
|
|
print("generating FR doc now with pandoc")
|
|
|
|
status = subprocess.call(["pandoc", "puredata_fr.md", "-o", "index_fr.html"])
|
|
|
|
print("generating EN doc now with pandoc")
|
|
|
|
status = subprocess.call(["pandoc", "puredata.md", "-o", "index_en.html"])
|
2019-05-28 20:00:09 +02:00
|
|
|
if status is 0:
|
|
|
|
print("success... will run now!")
|
|
|
|
bottle.run(host=HOST, port=PORT)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|