prod config for docker specific path
This commit is contained in:
parent
8fec12133b
commit
fbf34ffcdb
@ -19,3 +19,11 @@ Script to run:
|
|||||||
1. csv -> marp markdown converter
|
1. csv -> marp markdown converter
|
||||||
2. md -> pdf conversion using mark cli docker image
|
2. md -> pdf conversion using mark cli docker image
|
||||||
|
|
||||||
|
file upload based on
|
||||||
|
https://pythonise.com/series/learning-flask/flask-uploading-files
|
||||||
|
|
||||||
|
python docker wait for container
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
6
config.yml
Normal file
6
config.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
auth:
|
||||||
|
username: admin
|
||||||
|
hashedPassword: pbkdf2:sha256:150000$gWnHgdeJ$778d54af56408b434fdd7151f4d8ea88e1ad7525d47326aa70671962e1f654a1
|
||||||
|
prod: False
|
||||||
|
outputPath: './output'
|
||||||
|
uploadPath: './upload'
|
22
config_parser.py
Normal file
22
config_parser.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import yaml
|
||||||
|
import os
|
||||||
|
|
||||||
|
DEFAULT_CONFIG_FILE_NAME = "config.yml"
|
||||||
|
|
||||||
|
if os.environ['ENV'] == 'prod':
|
||||||
|
config_file_to_load = "config_prod.yml"
|
||||||
|
else:
|
||||||
|
config_file_to_load = DEFAULT_CONFIG_FILE_NAME
|
||||||
|
|
||||||
|
# BASE_FODLER = "/code/markdowntagebuch"
|
||||||
|
BASE_FODLER = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
path_to_config = os.path.join(BASE_FODLER, config_file_to_load)
|
||||||
|
print("opening config file " + path_to_config)
|
||||||
|
with open(path_to_config, "r") as ymlfile:
|
||||||
|
cfg = yaml.load(ymlfile, Loader=yaml.FullLoader)
|
||||||
|
|
||||||
|
credentials = cfg["auth"]
|
||||||
|
prod_mode = cfg["prod"]
|
||||||
|
output_path = cfg["outputPath"]
|
||||||
|
upload_path = cfg["uploadPath"]
|
6
config_prod.yml
Normal file
6
config_prod.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
auth:
|
||||||
|
username: admin
|
||||||
|
hashedPassword: pbkdf2:sha256:150000$gWnHgdeJ$778d54af56408b434fdd7151f4d8ea88e1ad7525d47326aa70671962e1f654a1
|
||||||
|
prod: True
|
||||||
|
outputPath: './csv-to-marp-converter/output'
|
||||||
|
uploadPath: './csv-to-marp-converter/upload'
|
@ -9,6 +9,9 @@ import shutil
|
|||||||
NUMBER_OF_ANSWERS = 5
|
NUMBER_OF_ANSWERS = 5
|
||||||
# BASE_FODLER = "test_data"
|
# BASE_FODLER = "test_data"
|
||||||
|
|
||||||
|
import config_parser
|
||||||
|
OUTPUT_FODLER = config_parser.output_path
|
||||||
|
|
||||||
|
|
||||||
class QuestionAndAnswers:
|
class QuestionAndAnswers:
|
||||||
def __init__(self, question, answerArray, category):
|
def __init__(self, question, answerArray, category):
|
||||||
@ -28,7 +31,7 @@ def convert(csv_path, output_pdf=False):
|
|||||||
|
|
||||||
def write_markdown_file(csv_path):
|
def write_markdown_file(csv_path):
|
||||||
# csv_path = "quiz-example.csv"
|
# csv_path = "quiz-example.csv"
|
||||||
OUTPUT_FODLER = "output"
|
# OUTPUT_FODLER = "output"
|
||||||
|
|
||||||
if not os.path.exists(OUTPUT_FODLER):
|
if not os.path.exists(OUTPUT_FODLER):
|
||||||
os.makedirs(OUTPUT_FODLER)
|
os.makedirs(OUTPUT_FODLER)
|
||||||
@ -116,7 +119,7 @@ def to_pdf(filename):
|
|||||||
current_dir = os.getcwd()
|
current_dir = os.getcwd()
|
||||||
print(current_dir)
|
print(current_dir)
|
||||||
|
|
||||||
OUTPUT_FODLER = "output"
|
# OUTPUT_FODLER = "output"
|
||||||
output_folder_path = os.path.join(current_dir, OUTPUT_FODLER)
|
output_folder_path = os.path.join(current_dir, OUTPUT_FODLER)
|
||||||
|
|
||||||
# https://docker-py.readthedocs.io/en/stable/containers.html
|
# https://docker-py.readthedocs.io/en/stable/containers.html
|
||||||
|
@ -17,3 +17,5 @@ urllib3==1.26.5
|
|||||||
websocket-client==1.1.0
|
websocket-client==1.1.0
|
||||||
Werkzeug==2.0.1
|
Werkzeug==2.0.1
|
||||||
zipp==3.4.1
|
zipp==3.4.1
|
||||||
|
PyYAML==5.4.1
|
||||||
|
pywin32==301 # needed for docker error messages
|
||||||
|
@ -28,8 +28,12 @@ URL_BASE_PATH = "/"
|
|||||||
# check_password_hash(config_parser.credentials['hashedPassword'], password):
|
# check_password_hash(config_parser.credentials['hashedPassword'], password):
|
||||||
# return username
|
# return username
|
||||||
|
|
||||||
OUTPUT_FODLER = "output"
|
# OUTPUT_FODLER = "output"
|
||||||
UPLOAD_FODLER = "upload"
|
# UPLOAD_FODLER = "upload"
|
||||||
|
|
||||||
|
import config_parser
|
||||||
|
|
||||||
|
UPLOAD_FODLER = config_parser.upload_path
|
||||||
|
|
||||||
# @app.route(URL_BASE_PATH + 'home', methods=['GET'])
|
# @app.route(URL_BASE_PATH + 'home', methods=['GET'])
|
||||||
# # @auth.login_required
|
# # @auth.login_required
|
||||||
@ -55,6 +59,7 @@ def upload_image():
|
|||||||
if not os.path.exists(UPLOAD_FODLER):
|
if not os.path.exists(UPLOAD_FODLER):
|
||||||
os.makedirs(UPLOAD_FODLER)
|
os.makedirs(UPLOAD_FODLER)
|
||||||
|
|
||||||
|
# TODO save to different path in Porduction!
|
||||||
csv_file.save(output_file_path)
|
csv_file.save(output_file_path)
|
||||||
|
|
||||||
# run converter
|
# run converter
|
||||||
|
Loading…
x
Reference in New Issue
Block a user