|
@ -1,30 +1,26 @@ |
|
|
# https://github.com/python-escpos/python-escpos |
|
|
|
|
|
# https://python-escpos.readthedocs.io/en/latest/ |
|
|
|
|
|
|
|
|
|
|
|
import flask |
|
|
import flask |
|
|
from flask import request |
|
|
from flask import request |
|
|
# import flask_apscheduler |
|
|
|
|
|
import urllib, json |
|
|
import urllib, json |
|
|
import os |
|
|
import os |
|
|
|
|
|
|
|
|
# Create the application. |
|
|
# Create the application. |
|
|
APP = flask.Flask(__name__) |
|
|
APP = flask.Flask(__name__) |
|
|
|
|
|
|
|
|
# Recurrent actions |
|
|
# --- |
|
|
# scheduler = flask_apscheduler.APScheduler() |
|
|
|
|
|
# scheduler.api_enabled = False |
|
|
#The following three lines are the variables that need to be changed when making a new project. |
|
|
# scheduler.init_app(APP) |
|
|
|
|
|
# scheduler.start() |
|
|
PROJECTNAME = 'dsn' |
|
|
|
|
|
DIR_PATH = '/home/systers/dsn-documentation' │·························· |
|
|
|
|
|
PORTNUMBER = 5599 |
|
|
|
|
|
|
|
|
|
|
|
# --- |
|
|
|
|
|
|
|
|
# @scheduler.task('interval', id='check', minutes=1) |
|
|
|
|
|
# def action(): |
|
|
|
|
|
# print('Do something recurrent') |
|
|
|
|
|
|
|
|
|
|
|
pads = [ |
|
|
pads = [ |
|
|
'RDI.md', |
|
|
f'{ PROJECTNAME }.md', |
|
|
'RDI.css' |
|
|
f'{ PROJECTNAME }.css' |
|
|
] |
|
|
] |
|
|
DIR_PATH = '/home/systers/rdi-flask-interface' |
|
|
|
|
|
|
|
|
|
|
|
def download(pads): |
|
|
def download(pads): |
|
|
# using etherpump |
|
|
# using etherpump |
|
@ -39,35 +35,24 @@ def pad(): |
|
|
def pagedjs(): |
|
|
def pagedjs(): |
|
|
# download the main post-script pad + stylesheet pad |
|
|
# download the main post-script pad + stylesheet pad |
|
|
download(pads) |
|
|
download(pads) |
|
|
# generate html page |
|
|
# generate html page with the pandoc template (with paged.js inserted in the header) |
|
|
os.system(f'pandoc -f markdown -t html -c RDI.css --toc --toc-depth=1 --template { DIR_PATH }/templates/pandoc-template-pagedjs.html --standalone { DIR_PATH }/static/RDI.md -o { DIR_PATH }/static/RDI.pagedjs.html') |
|
|
os.system(f'pandoc -f markdown -t html -c { PROJECTNAME }.css --toc --toc-depth=1 --template { DIR_PATH }/templates/pandoc-template-pagedjs.html --standalone { DIR_PATH }/static/{ PROJECTNAME }.md -o { DIR_PATH }/static/{ PROJECTNAME }.pagedjs.html') |
|
|
|
|
|
|
|
|
return open('static/RDI.pagedjs.html', 'r').read() |
|
|
return open('static/{ PROJECTNAME }.pagedjs.html', 'r').read() |
|
|
|
|
|
|
|
|
@APP.route('/html/', methods=['GET', 'POST']) |
|
|
@APP.route('/html/', methods=['GET', 'POST']) |
|
|
def html(): |
|
|
def html(): |
|
|
# download the main post-script pad + stylesheet pad |
|
|
# download the main post-script pad + stylesheet pad |
|
|
download(pads) |
|
|
download(pads) |
|
|
# generate html page |
|
|
# generate html page |
|
|
os.system(f'pandoc -f markdown -t html -c RDI.css --toc --toc-depth=1 --standalone { DIR_PATH }/static/RDI.md -o { DIR_PATH }/static/RDI.html') |
|
|
os.system(f'pandoc -f markdown -t html -c { PROJECTNAME }.css --toc --toc-depth=1 --standalone { DIR_PATH }/static/{ PROJECTNAME }.md -o { DIR_PATH }/static/{ PROJECTNAME }.html') |
|
|
|
|
|
|
|
|
return flask.render_template('html.html') |
|
|
return flask.render_template('html.html') |
|
|
|
|
|
|
|
|
#@APP.route('/pdf/', methods=['GET']) |
|
|
|
|
|
#def pdf(): |
|
|
|
|
|
# download the main post-script pad + stylesheet pad |
|
|
|
|
|
#download(pads) |
|
|
|
|
|
# generate html page |
|
|
|
|
|
#os.system(f'pandoc -f markdown -t html -c post-script.css --toc --toc-depth=1 --standalone { DIR_PATH }/static/post-script.md -o { DIR_PATH }/static/post-script.html') |
|
|
|
|
|
# generate pdf |
|
|
|
|
|
#os.system(f'{ DIR_PATH }/venv/bin/weasyprint -s { DIR_PATH }/static/post-script.css { DIR_PATH }/static/post-script.html { DIR_PATH }/static/post-script.pdf') |
|
|
|
|
|
|
|
|
|
|
|
#return flask.render_template('pdf.html') |
|
|
|
|
|
|
|
|
|
|
|
@APP.route('/stylesheet/', methods=['GET']) |
|
|
@APP.route('/stylesheet/', methods=['GET']) |
|
|
def stylesheet(): |
|
|
def stylesheet(): |
|
|
return flask.render_template('stylesheet.html') |
|
|
return flask.render_template('stylesheet.html') |
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
if __name__ == '__main__': |
|
|
APP.debug=True |
|
|
APP.debug=True |
|
|
APP.run(port=5588) |
|
|
APP.run(port={ PORTNUMBER }) |
|
|