diff --git a/.gitignore b/.gitignore index 0a6e27e..9dac8e3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .idea csvmarp +csvconvertervenv # ---> Python # Byte-compiled / optimized / DLL files diff --git a/README.md b/README.md index 9a59aa5..3c34d7f 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,13 @@ Strings surrounded with quotation marks The [marp-cli](https://github.com/marp-team/marp-cli) can be used to convert the md to pdf: - Stand alone linux package https://github.com/marp-team/marp-cli/releases + - run as server with PORT=5000 marp -s ./slides + - requires wget for download + - requires chrome to convert to pdf - docker container https://hub.docker.com/r/marpteam/marp-cli/ `docker run --rm --init -v $PWD:/home/marp/app/ -e LANG=$LANG marpteam/marp-cli slide-deck.md --pdf` + - Run marp cli in its own docker container in server mode!!! + - output folder as volumne, so that marp container can assess it powerpoint export is also possible with --pptx @@ -32,5 +37,48 @@ https://pythonise.com/series/learning-flask/flask-uploading-files python docker wait for container +CLI binary: + +convert file +./marp --pdf ./slides/slide-deck.md +./marp --pdf ./slides/slide-deck.md +/opt/marp --pdf /code/csv-to-marp-converter/ + +start server +./marp --pdf --server ./slides/ +PORT=4100 /opt/marp-cli --server ./ + + +use marp server: + - link or embed marp server path (http://localhost:8080/) from result html + - Dockerfile + - download latest marp binary + - start server (on correct port) + +wget -O marp-cli.tar.gz https://github.com/marp-team/marp-cli/releases/download/v1.1.1/marp-cli-v1.1.1-linux.tar.gz + + +when running release version from + +[ WARN ] The environment variable CHROME_PATH must be set to executable of a build of Chromium version 54.0 or later. +[ ERROR ] Failed converting Markdown. (You have to install Google Chrome, Chromium, or Microsoft Edge to convert slide deck with current options.) + + +when running cli with docker +docker run -v $PWD:/home/marp/app/ -e LANG=$LANG marpteam/marp-cli quiz-slides-template.md --pdf + +[ ERROR ] Failed converting Markdown. (EACCES: permission denied, open + '/home/marp/app/quiz-slides-template.pdf') + +chmod -R 0777 output/ + +docker run -v $PWD:/home/marp/app/ -e LANG=$LANG -e PORT=4100 -p 4100:4100 marpteam/marp-cli --server ./ -d + +docker run -d -v /home/marcelo/git/docker-python-multi-service/csv-to-marp-converter/output:/home/marp/app/ -e LANG=$LANG -e PORT=4100 -p 4100:4100 marpteam/marp-cli --server ./ + +run on NAS: +sudo docker run -d -v /volume1/docker/dockerpython/docker-python-multi-service/csv-marp-converter-output:/home/marp/app/ -e LANG=$LANG -e PORT=4100 -p 4100:4100 --name marp marpteam/marp-cli --server -I ./ + - Folder that is mounted should not be empty!! + diff --git a/rest_server.py b/rest_server.py index 480715a..4cde63b 100644 --- a/rest_server.py +++ b/rest_server.py @@ -61,7 +61,10 @@ def upload_image(): csv_file.save(output_file_path) # run converter - converter.convert(output_file_path, True) + if config_parser.prod_mode: + converter.convert(output_file_path, False) + else: + converter.convert(output_file_path, True) return render_template("return_result.html") # return redirect(request.url) @@ -112,6 +115,17 @@ def valid_csv(filename): # # return "bla" # return render_template("tagebuch_output.html", markdown_result=data, markdown_filename=filename) +def get_marp_url(): + if config_parser.prod_mode: + return "https://marp.swaghausen.de" + else: + return "http://localhost:4100" + +@app.route('/marp') +def redirect_to_marp(): + return redirect(get_marp_url(), code=302) + # return get_marp_url() + @app.route(URL_BASE_PATH + 'download', methods=['GET']) # @auth.login_required diff --git a/templates/return_result.html b/templates/return_result.html index ffafe84..649eef7 100644 --- a/templates/return_result.html +++ b/templates/return_result.html @@ -11,5 +11,6 @@ Download Markdown File Download PDF File + Go To Marp Server

{% endblock %} \ No newline at end of file