initial commit

This commit is contained in:
nihonium 2023-01-15 13:53:21 +03:00
commit 3b3c9a9417
Signed by: nihonium
GPG key ID: 0251623741027CFC
258 changed files with 20086 additions and 0 deletions

View file

@ -0,0 +1,16 @@
FROM python:3-slim
RUN useradd -ms /bin/bash volgactf
RUN pip install --no-cache-dir flask
WORKDIR /home/volgactf/dist
COPY . ./
RUN chown -R volgactf:volgactf /home/volgactf/dist
USER volgactf
CMD python app.py

View file

@ -0,0 +1,51 @@
from flask import Flask, send_from_directory, current_app, request, jsonify
from werkzeug.utils import secure_filename
import os
import glob
app = Flask(__name__)
@app.route('/health_check', methods=['GET'])
def health_check():
return "OK", 200
@app.route('/<string:path>', methods=['GET'])
def download(path):
filename = secure_filename(request.args.get("filename"))
uploads = os.path.join(current_app.root_path, path) #file_upload ????
return send_from_directory(directory=uploads, path=filename)
@app.route('/file_list/<string:path>', methods=['GET'])
def file_list(path):
file_list = []
for files in glob.glob(current_app.root_path+'/'+path + '/*'):
file_list.append(files.split('/')[-1])
return jsonify(file_list)
@app.route('/upload/<string:path>', methods=['POST'])
def upload(path):
key = request.files
file = request.files.get(next(iter(key)))
filename = secure_filename(file.filename)
uploads = os.path.join(current_app.root_path, path)
if not os.path.exists(uploads):
os.mkdir(uploads)
file.save(uploads+"/"+filename)
return jsonify({"filename": filename})
@app.route('/delete', methods=['GET'])
def delete():
filename = request.args.get("filename")
filename = secure_filename(filename)
path = "secrets"
delete_path = os.path.join(current_app.root_path, path)
if os.path.exists(delete_path+"/"+filename):
os.remove(delete_path+"/"+filename)
return jsonify({"result": "ok"})
else:
return jsonify({"result": "NOT OK"})
if __name__ == '__main__':
app.run(debug=False, host="0.0.0.0", port=13379)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB