Add primitive file uploading for testing

This commit is contained in:
František Kmječ 2021-01-22 21:17:08 +01:00
parent 697165fb63
commit 3dee27732c
4 changed files with 29 additions and 2 deletions

View File

@ -1 +1,2 @@
env/
__pycache__/

View File

@ -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()

View File

@ -0,0 +1,9 @@
<html>
<body>
<form action = "http://localhost:5000/validator" method = "POST"
enctype = "multipart/form-data">
<input type = "file" name = "file" /> <!-- TODO hláška-->
<input type = "submit"/>
</form>
</body>
</html>

View File

@ -29,3 +29,6 @@ def validate_signature():
def validate_date():
pass
def validate(text):
pass