Compare commits
4 Commits
56bd031229
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
91fd586a07 | ||
|
5d41b451cf | ||
|
155b28cb46 | ||
|
dbe862cf53 |
@@ -1,6 +1,6 @@
|
|||||||
auth:
|
auth:
|
||||||
username: admin
|
username: admin
|
||||||
hashedPassword: pbkdf2:sha256:150000$gWnHgdeJ$778d54af56408b434fdd7151f4d8ea88e1ad7525d47326aa70671962e1f654a1
|
hashedPassword: pbkdf2:sha256:260000$2xn3u8v9EFHM7oj1$65a9126ae01129a8adc5ca74ec6c006388f3d7f0176d015dccf8e0bf1f5e2523
|
||||||
prod: False
|
prod: False
|
||||||
basePath: './'
|
basePath: './'
|
||||||
outputPath: './output'
|
outputPath: './output'
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
auth:
|
auth:
|
||||||
username: admin
|
username: admin
|
||||||
hashedPassword: pbkdf2:sha256:150000$gWnHgdeJ$778d54af56408b434fdd7151f4d8ea88e1ad7525d47326aa70671962e1f654a1
|
hashedPassword: pbkdf2:sha256:260000$2xn3u8v9EFHM7oj1$65a9126ae01129a8adc5ca74ec6c006388f3d7f0176d015dccf8e0bf1f5e2523
|
||||||
prod: True
|
prod: True
|
||||||
basePath: './csv-to-marp-converter'
|
basePath: './csv-to-marp-converter'
|
||||||
outputPath: './csv-to-marp-converter/output'
|
outputPath: './csv-to-marp-converter/output'
|
||||||
|
16
converter.py
16
converter.py
@@ -1,15 +1,9 @@
|
|||||||
import os
|
import os
|
||||||
import shutil
|
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
|
import config_parser
|
||||||
|
|
||||||
|
NUMBER_OF_ANSWERS = 5
|
||||||
|
|
||||||
OUTPUT_FODLER = config_parser.output_path
|
OUTPUT_FODLER = config_parser.output_path
|
||||||
BASE_FODLER = config_parser.base_path
|
BASE_FODLER = config_parser.base_path
|
||||||
|
|
||||||
@@ -63,6 +57,8 @@ def write_markdown_file(csv_path):
|
|||||||
# copy template
|
# copy template
|
||||||
template_name = "quiz-slides-template.md"
|
template_name = "quiz-slides-template.md"
|
||||||
template_path = os.path.join(BASE_FODLER, template_name)
|
template_path = os.path.join(BASE_FODLER, template_name)
|
||||||
|
# print("template_path")
|
||||||
|
# print(template_path)
|
||||||
|
|
||||||
shutil.copyfile(template_path, markdown_path)
|
shutil.copyfile(template_path, markdown_path)
|
||||||
|
|
||||||
@@ -103,7 +99,7 @@ def handle_q_and_a_row(line, list_of_q_and_as, category):
|
|||||||
column_data = line.split(',')
|
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
|
# 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
|
# check size of array
|
||||||
print(len(column_data))
|
# print(len(column_data))
|
||||||
if len(column_data) is NUMBER_OF_ANSWERS:
|
if len(column_data) is NUMBER_OF_ANSWERS:
|
||||||
question = column_data[0]
|
question = column_data[0]
|
||||||
answers = column_data[1:] # select all elements from list except first
|
answers = column_data[1:] # select all elements from list except first
|
||||||
|
@@ -5,6 +5,7 @@ colorama==0.4.4
|
|||||||
docker==5.0.0
|
docker==5.0.0
|
||||||
Flask==2.0.1
|
Flask==2.0.1
|
||||||
Flask-Cors==3.0.10
|
Flask-Cors==3.0.10
|
||||||
|
Flask-HTTPAuth==4.3.0
|
||||||
idna==3.2
|
idna==3.2
|
||||||
importlib-metadata==4.5.0
|
importlib-metadata==4.5.0
|
||||||
itsdangerous==2.0.1
|
itsdangerous==2.0.1
|
||||||
|
@@ -3,46 +3,35 @@ import os
|
|||||||
from flask import Flask
|
from flask import Flask
|
||||||
from flask import render_template
|
from flask import render_template
|
||||||
from flask import request, send_from_directory
|
from flask import request, send_from_directory
|
||||||
from flask import url_for
|
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
# from flask_httpauth import HTTPBasicAuth
|
from flask_httpauth import HTTPBasicAuth
|
||||||
# from werkzeug.security import check_password_hash
|
from werkzeug.security import check_password_hash
|
||||||
# import main
|
|
||||||
from werkzeug.utils import redirect
|
from werkzeug.utils import redirect
|
||||||
|
|
||||||
# import config_parser
|
|
||||||
# from md_tagebuch import diary
|
|
||||||
import converter
|
import converter
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
# auth = HTTPBasicAuth()
|
auth = HTTPBasicAuth()
|
||||||
app.config["DEBUG"] = True
|
app.config["DEBUG"] = True
|
||||||
CORS(app)
|
CORS(app)
|
||||||
|
|
||||||
URL_BASE_PATH = "/"
|
URL_BASE_PATH = "/"
|
||||||
# URL_BASE_PATH = "/tagebuch"
|
|
||||||
|
|
||||||
# @auth.verify_password
|
|
||||||
# def verify_password(username, password):
|
|
||||||
# if username == config_parser.credentials['username'] and \
|
|
||||||
# check_password_hash(config_parser.credentials['hashedPassword'], password):
|
|
||||||
# return username
|
|
||||||
|
|
||||||
# OUTPUT_FODLER = "output"
|
|
||||||
# UPLOAD_FODLER = "upload"
|
|
||||||
|
|
||||||
import config_parser
|
import config_parser
|
||||||
|
|
||||||
UPLOAD_FODLER = config_parser.upload_path
|
UPLOAD_FODLER = config_parser.upload_path
|
||||||
OUTPUT_FODLER = config_parser.output_path
|
OUTPUT_FODLER = config_parser.output_path
|
||||||
|
|
||||||
# @app.route(URL_BASE_PATH + 'home', methods=['GET'])
|
|
||||||
# # @auth.login_required
|
@auth.verify_password
|
||||||
# def api_show_form():
|
def verify_password(username, password):
|
||||||
# return render_template("index.html")
|
if username == config_parser.credentials['username'] and \
|
||||||
|
check_password_hash(config_parser.credentials['hashedPassword'], password):
|
||||||
|
return username
|
||||||
|
|
||||||
|
|
||||||
@app.route(URL_BASE_PATH, methods=["GET", "POST"])
|
@app.route(URL_BASE_PATH, methods=["GET", "POST"])
|
||||||
|
@auth.login_required
|
||||||
def upload_image():
|
def upload_image():
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
if request.files:
|
if request.files:
|
||||||
@@ -76,7 +65,6 @@ def upload_image():
|
|||||||
|
|
||||||
|
|
||||||
def valid_csv(filename):
|
def valid_csv(filename):
|
||||||
|
|
||||||
# We only want files with a . in the filename
|
# We only want files with a . in the filename
|
||||||
if not "." in filename:
|
if not "." in filename:
|
||||||
return False
|
return False
|
||||||
@@ -86,44 +74,13 @@ def valid_csv(filename):
|
|||||||
return ext == 'csv'
|
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():
|
def get_marp_url():
|
||||||
if config_parser.prod_mode:
|
if config_parser.prod_mode:
|
||||||
return "https://marp.swaghausen.de"
|
return "https://marp.swaghausen.de"
|
||||||
else:
|
else:
|
||||||
return "http://localhost:4100"
|
return "http://localhost:4100"
|
||||||
|
|
||||||
|
|
||||||
@app.route('/marp')
|
@app.route('/marp')
|
||||||
def redirect_to_marp():
|
def redirect_to_marp():
|
||||||
return redirect(get_marp_url(), code=302)
|
return redirect(get_marp_url(), code=302)
|
||||||
@@ -138,7 +95,7 @@ def download_file():
|
|||||||
current_dir = os.getcwd()
|
current_dir = os.getcwd()
|
||||||
full_dir = os.path.join(current_dir, OUTPUT_FODLER)
|
full_dir = os.path.join(current_dir, OUTPUT_FODLER)
|
||||||
print("full_dir: " + full_dir)
|
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'])
|
@app.route(URL_BASE_PATH + 'download-pdf', methods=['GET'])
|
||||||
|
Reference in New Issue
Block a user