From 3dee27732c57594532138c4fac7987862f6a21b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Kmje=C4=8D?= Date: Fri, 22 Jan 2021 21:17:08 +0100 Subject: [PATCH] Add primitive file uploading for testing --- validator/.gitignore | 1 + validator/server.py | 18 ++++++++++++++++-- validator/templates/index.html | 9 +++++++++ validator/validator.py | 3 +++ 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 validator/templates/index.html diff --git a/validator/.gitignore b/validator/.gitignore index bdaab25..06a47c5 100644 --- a/validator/.gitignore +++ b/validator/.gitignore @@ -1 +1,2 @@ env/ +__pycache__/ diff --git a/validator/server.py b/validator/server.py index 770473d..46e4940 100644 --- a/validator/server.py +++ b/validator/server.py @@ -1,10 +1,24 @@ -from flask import Flask +from flask import Flask, render_template, request import json +import validator app = Flask(__name__) @app.route('/') def index(): - return json.dumps({"Hello": "World!"}) + return render_template('index.html') + +@app.route('/validator', methods=['GET', 'POST']) +def validate(): + if request.method == 'POST': + print(request.files) + f = request.files['file'] + + text = validator.process_file(f) + result = validator.validate(text) + return jsonify(result) + else: + return 'Soubor byl zvalidován. TODO musím ověřit, jak byl zvalidován.' # TODO change + app.run() \ No newline at end of file diff --git a/validator/templates/index.html b/validator/templates/index.html new file mode 100644 index 0000000..aeb843c --- /dev/null +++ b/validator/templates/index.html @@ -0,0 +1,9 @@ + + +
+ + +
+ + \ No newline at end of file diff --git a/validator/validator.py b/validator/validator.py index 8bc3cd1..f3dffe2 100644 --- a/validator/validator.py +++ b/validator/validator.py @@ -28,4 +28,7 @@ def validate_signature(): pass def validate_date(): + pass + +def validate(text): pass \ No newline at end of file