diff options
Diffstat (limited to 'admin/admin.py')
-rw-r--r-- | admin/admin.py | 39 |
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 | |||
3 | import pygit2 | ||
4 | from flask import Flask, render_template, jsonify, request, redirect, send_from_directory | ||
5 | from flask_dropzone import Dropzone | ||
6 | from argparse import ArgumentParser | ||
7 | |||
8 | app = Flask(__name__) | ||
9 | app.config['SECRET_KEY'] = 'OlbodTyshnokTyafveg' | ||
10 | |||
11 | app.config['PREFERRED_URL_SCHEME'] = 'https' | ||
12 | app.config['DROPZONE_SERVE_LOCAL'] = True | ||
13 | app.config['DROPZONE_MAX_FILE_SIZE'] = 128 | ||
14 | app.config['DROPZONE_UPLOAD_MULTIPLE'] = True | ||
15 | app.config['DROPZONE_PARALLEL_UPLOADS'] = 10 | ||
16 | |||
17 | app.config['DROPZONE_ALLOWED_FILE_CUSTOM'] = True | ||
18 | app.config['DROPZONE_ALLOWED_FILE_TYPE'] = '' | ||
19 | |||
20 | app.config['DROPZONE_DEFAULT_MESSAGE'] = 'Ziehe die Dateien hier hin, um sie hochzuladen oder klicken Sie zur Auswahl.' | ||
21 | |||
22 | dropzone = Dropzone(app) | ||
23 | |||
24 | @app.route("/admin", methods=['GET']) | ||
25 | def 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 | |||
32 | if __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)) | ||