summaryrefslogtreecommitdiff
path: root/admin/admin.py
blob: cbd92192881f5e15d929387cce0db1a0e0911d01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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))