summaryrefslogtreecommitdiff
path: root/admin/admin.py
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2020-06-02 18:33:32 +0200
committerDirk Engling <erdgeist@erdgeist.org>2020-06-02 18:33:32 +0200
commitb2fff1c0cb13d720e305f7835044da7360aab273 (patch)
tree3d3b3062e87c9f16c5756ba723e22134e5a24d05 /admin/admin.py
parent6c61efddf9080194115106d6eaec7e57df66e1a2 (diff)
Add simple admin interface testHEADmaster
Diffstat (limited to 'admin/admin.py')
-rw-r--r--admin/admin.py39
1 files changed, 39 insertions, 0 deletions
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 @@
1#!python3
2
3import pygit2
4from flask import Flask, render_template, jsonify, request, redirect, send_from_directory
5from flask_dropzone import Dropzone
6from argparse import ArgumentParser
7
8app = Flask(__name__)
9app.config['SECRET_KEY'] = 'OlbodTyshnokTyafveg'
10
11app.config['PREFERRED_URL_SCHEME'] = 'https'
12app.config['DROPZONE_SERVE_LOCAL'] = True
13app.config['DROPZONE_MAX_FILE_SIZE'] = 128
14app.config['DROPZONE_UPLOAD_MULTIPLE'] = True
15app.config['DROPZONE_PARALLEL_UPLOADS'] = 10
16
17app.config['DROPZONE_ALLOWED_FILE_CUSTOM'] = True
18app.config['DROPZONE_ALLOWED_FILE_TYPE'] = ''
19
20app.config['DROPZONE_DEFAULT_MESSAGE'] = 'Ziehe die Dateien hier hin, um sie hochzuladen oder klicken Sie zur Auswahl.'
21
22dropzone = Dropzone(app)
23
24@app.route("/admin", methods=['GET'])
25def admin():
26 repo = pygit2.Repository('.')
27 commit = repo[repo.lookup_branch("master").target]
28
29 url_root = request.url_root.replace('http://', 'https://', 1)
30 return render_template('index.html', tree = commit.tree, url_root = url_root)
31
32if __name__ == "__main__":
33 parser = ArgumentParser(description="CCCMS")
34 parser.add_argument("-H", "--host", help="Hostname of the Flask app " + "[default %s]" % "127.0.0.1", default="127.0.0.1")
35 parser.add_argument("-P", "--port", help="Port for the Flask app " + "[default %s]" % "5000", default="5000")
36
37 args = parser.parse_args()
38
39 app.run(host=args.host, port=int(args.port))