diff --git a/converter.py b/converter.py index 2c96744..779ff46 100644 --- a/converter.py +++ b/converter.py @@ -1,15 +1,9 @@ import os import shutil - -# def file_exists(filename): -# if os.path.exists(filename): -# print('Note: Diary \'' + filename + '\' already exists. Will not be modified.') -# return True -# return False -NUMBER_OF_ANSWERS = 5 -# BASE_FODLER = "test_data" - import config_parser + +NUMBER_OF_ANSWERS = 5 + OUTPUT_FODLER = config_parser.output_path BASE_FODLER = config_parser.base_path @@ -105,7 +99,7 @@ def handle_q_and_a_row(line, list_of_q_and_as, category): column_data = line.split(',') # print(column_data) # causes UnicodeEncodeError: 'ascii' codec can't encode character '\xf6' in position 49: ordinal not in range(128) in linux # check size of array - print(len(column_data)) + # print(len(column_data)) if len(column_data) is NUMBER_OF_ANSWERS: question = column_data[0] answers = column_data[1:] # select all elements from list except first @@ -121,7 +115,7 @@ def handle_q_and_a_row(line, list_of_q_and_as, category): def to_pdf(filename): import docker client = docker.from_env() - + current_dir = os.getcwd() # OUTPUT_FODLER = "output" output_folder_path = os.path.join(current_dir, OUTPUT_FODLER) diff --git a/rest_server.py b/rest_server.py index 4cde63b..ae727ab 100644 --- a/rest_server.py +++ b/rest_server.py @@ -3,14 +3,11 @@ import os from flask import Flask from flask import render_template from flask import request, send_from_directory -from flask import url_for from flask_cors import CORS from flask_httpauth import HTTPBasicAuth from werkzeug.security import check_password_hash from werkzeug.utils import redirect -# import config_parser -# from md_tagebuch import diary import converter app = Flask(__name__) @@ -25,11 +22,6 @@ import config_parser UPLOAD_FODLER = config_parser.upload_path OUTPUT_FODLER = config_parser.output_path -# @app.route(URL_BASE_PATH + 'home', methods=['GET']) -# # @auth.login_required -# def api_show_form(): -# return render_template("index.html") - @auth.verify_password def verify_password(username, password): @@ -73,7 +65,6 @@ def upload_image(): def valid_csv(filename): - # We only want files with a . in the filename if not "." in filename: return False @@ -83,44 +74,13 @@ def valid_csv(filename): return ext == 'csv' - -# -# @app.route(URL_BASE_PATH, methods=['POST', 'GET']) -# # @auth.login_required -# def tagebuch(): -# if request.method == "POST": -# user_input = request.form['yearmonth'] -# return redirect(url_for("return_result", yearmonth=user_input)) -# else: -# return render_template("tagebuch.html") -# -# -# @app.route(URL_BASE_PATH + "") -# # @auth.login_required -# def return_result(yearmonth): -# print(os.getcwd()) -# filename = "slide-deck.md" -# -# print("filename to be served: " + filename) -# data = "test" -# full_file_path = os.path.join(OUTPUT_FODLER, filename) -# -# if os.path.exists(full_file_path): -# with open(full_file_path, 'r', encoding='UTF-8') as open_file: -# data = open_file.read() -# # return data -# # print(data) -# # open_file.close() -# # return f"

{yearmonth}

" -# # 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) @@ -135,9 +95,9 @@ def download_file(): current_dir = os.getcwd() full_dir = os.path.join(current_dir, OUTPUT_FODLER) print("full_dir: " + full_dir) - return send_from_directory(full_dir, "slide-deck.md", as_attachment=True)\ - - + return send_from_directory(full_dir, "slide-deck.md", as_attachment=True) \ + \ + \ @app.route(URL_BASE_PATH + 'download-pdf', methods=['GET']) # @auth.login_required def download_pdf_file():