This commit is contained in:
dechert 2021-06-21 12:22:15 +02:00
parent 155b28cb46
commit 5d41b451cf
2 changed files with 9 additions and 55 deletions

View File

@ -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)

View File

@ -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 + "<yearmonth>")
# # @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"<h1>{yearmonth}</h1>"
# # 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():