From b2fff1c0cb13d720e305f7835044da7360aab273 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Tue, 2 Jun 2020 18:33:32 +0200 Subject: Add simple admin interface test --- admin/admin.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 admin/admin.py (limited to 'admin/admin.py') diff --git a/admin/admin.py b/admin/admin.py new file mode 100644 index 00000000..cbd92192 --- /dev/null +++ b/admin/admin.py @@ -0,0 +1,39 @@ +#!python3 + +import pygit2 +from flask import Flask, render_template, jsonify, request, redirect, send_from_directory +from flask_dropzone import Dropzone +from argparse import ArgumentParser + +app = Flask(__name__) +app.config['SECRET_KEY'] = 'OlbodTyshnokTyafveg' + +app.config['PREFERRED_URL_SCHEME'] = 'https' +app.config['DROPZONE_SERVE_LOCAL'] = True +app.config['DROPZONE_MAX_FILE_SIZE'] = 128 +app.config['DROPZONE_UPLOAD_MULTIPLE'] = True +app.config['DROPZONE_PARALLEL_UPLOADS'] = 10 + +app.config['DROPZONE_ALLOWED_FILE_CUSTOM'] = True +app.config['DROPZONE_ALLOWED_FILE_TYPE'] = '' + +app.config['DROPZONE_DEFAULT_MESSAGE'] = 'Ziehe die Dateien hier hin, um sie hochzuladen oder klicken Sie zur Auswahl.' + +dropzone = Dropzone(app) + +@app.route("/admin", methods=['GET']) +def admin(): + repo = pygit2.Repository('.') + commit = repo[repo.lookup_branch("master").target] + + url_root = request.url_root.replace('http://', 'https://', 1) + return render_template('index.html', tree = commit.tree, url_root = url_root) + +if __name__ == "__main__": + parser = ArgumentParser(description="CCCMS") + parser.add_argument("-H", "--host", help="Hostname of the Flask app " + "[default %s]" % "127.0.0.1", default="127.0.0.1") + parser.add_argument("-P", "--port", help="Port for the Flask app " + "[default %s]" % "5000", default="5000") + + args = parser.parse_args() + + app.run(host=args.host, port=int(args.port)) -- cgit v1.2.3