Updated Dockerfile

This commit is contained in:
lkrsnik 2023-12-06 16:35:15 +01:00
parent e71d656d0e
commit ab66eeb6e8
2 changed files with 217 additions and 213 deletions

View File

@ -5,4 +5,4 @@ RUN pip install --upgrade pip
RUN pip install waitress
RUN pip install .
CMD ["waitress-serve", "--call", "app:app"]
CMD ["waitress-serve", "--call", "app:create_app"]

40
app.py
View File

@ -9,17 +9,18 @@ import time
import requests
from flask import Flask, render_template, request, send_file, redirect, url_for
from werkzeug.utils import secure_filename
from stark import run
app = Flask(__name__)
UPLOAD_FOLDER = 'uploads'
ALLOWED_EXTENSIONS = {'conllu'}
DAYS_BEFORE_DELETION = 1
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
def create_default_configs():
def create_app():
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
def create_default_configs():
configs = {}
# mandatory parameters
configs['input_path'] = 'data/sl_ssj-ud_v2.4.conllu'
@ -55,36 +56,36 @@ def create_default_configs():
return configs
def allowed_file(filename):
def allowed_file(filename):
return '.' in filename and \
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
@app.route('/upload')
def upload_file2():
@app.route('/upload')
def upload_file2():
return render_template('upload.html')
@app.route('/uploader', methods=['GET', 'POST'])
def upload_file():
@app.route('/uploader', methods=['GET', 'POST'])
def upload_file():
if request.method == 'POST':
f = request.files['file']
f.save(secure_filename(f.filename))
return 'file uploaded successfully'
@app.route('/about', methods=['GET'])
def about():
@app.route('/about', methods=['GET'])
def about():
return render_template('about.html')
# @app.route('/result/<result_id>/download', methods=['GET'])
# def download_result(result_id):
# return
# @app.route('/result/<result_id>/download', methods=['GET'])
# def download_result(result_id):
# return
@app.route('/result/<result_id>', methods=['GET', 'POST'])
def result(result_id):
@app.route('/result/<result_id>', methods=['GET', 'POST'])
def result(result_id):
if request.method == 'POST':
for filename in os.listdir('media'):
@ -125,8 +126,8 @@ def result(result_id):
return render_template('result.html', head_row=head, content=content_dict)
@app.route('/', methods=['GET', 'POST'])
def index():
@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
form = request.form
configs = {}
@ -258,6 +259,9 @@ def index():
# return render_template('index.html')
return render_template('index.html')
return app
if __name__ == '__main__':
app = create_app()
app.run(debug=True)