web server updates for bilingual support
This commit is contained in:
		
							parent
							
								
									bfaf553581
								
							
						
					
					
						commit
						997d25d7f1
					
				| 
						 | 
					@ -3,7 +3,7 @@ import os.path
 | 
				
			||||||
import subprocess
 | 
					import subprocess
 | 
				
			||||||
 | 
					
 | 
				
			||||||
HOST = "0.0.0.0"
 | 
					HOST = "0.0.0.0"
 | 
				
			||||||
PORT = 8080
 | 
					PORT = 8000
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# this script runs a small webserver on HOST:PORT that return the class course
 | 
					# this script runs a small webserver on HOST:PORT that return the class course
 | 
				
			||||||
# all assets are stored in ./resources and available for download
 | 
					# all assets are stored in ./resources and available for download
 | 
				
			||||||
| 
						 | 
					@ -11,6 +11,18 @@ PORT = 8080
 | 
				
			||||||
# the bottle framework is needed to run this script
 | 
					# the bottle framework is needed to run this script
 | 
				
			||||||
# you can install it with "python3 -m pip install --user bottle"
 | 
					# you can install it with "python3 -m pip install --user bottle"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@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="./")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@bottle.route("/<filename>")
 | 
					@bottle.route("/<filename>")
 | 
				
			||||||
def index(filename):
 | 
					def index(filename):
 | 
				
			||||||
    if filename == "puredata":
 | 
					    if filename == "puredata":
 | 
				
			||||||
| 
						 | 
					@ -18,17 +30,20 @@ def index(filename):
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        return bottle.static_file(filename, root="./")
 | 
					        return bottle.static_file(filename, root="./")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@bottle.route("/screenshots/<filename>")
 | 
				
			||||||
 | 
					def resources(filename):
 | 
				
			||||||
 | 
					    return bottle.static_file(filename, root="screenshots")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@bottle.route("/resources/<filename>")
 | 
					@bottle.route("/resources/<filename>")
 | 
				
			||||||
def resources(filename):
 | 
					def resources(filename):
 | 
				
			||||||
    return bottle.static_file(filename, root="resources")
 | 
					    return bottle.static_file(filename, root="resources")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def main():
 | 
					def main():
 | 
				
			||||||
    if os.path.isfile("index.html"):
 | 
					        print("generating FR doc now with pandoc")
 | 
				
			||||||
        print("index.html is present, we can run!")
 | 
					        status = subprocess.call(["pandoc", "puredata_fr.md", "-o", "index_fr.html"])
 | 
				
			||||||
        bottle.run(host=HOST, port=PORT)
 | 
					        print("generating EN doc now with pandoc")
 | 
				
			||||||
    else:
 | 
					        status = subprocess.call(["pandoc", "puredata.md", "-o", "index_en.html"])
 | 
				
			||||||
        print("index.html not found, will generate it now with pandoc")
 | 
					 | 
				
			||||||
        status = subprocess.call(["pandoc", "puredata.md", "-o", "index.html"])
 | 
					 | 
				
			||||||
        if status is 0:
 | 
					        if status is 0:
 | 
				
			||||||
            print("success... will run now!")
 | 
					            print("success... will run now!")
 | 
				
			||||||
            bottle.run(host=HOST, port=PORT)
 | 
					            bottle.run(host=HOST, port=PORT)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue