Updated paths for deployment.

This commit is contained in:
2024-02-21 11:10:31 +01:00
parent ab6a905093
commit 28c7e9e4e1
6 changed files with 44 additions and 271 deletions
+26 -36
View File
@@ -60,7 +60,7 @@ def get_locale():
def create_app():
app = Flask(__name__)
app = Flask(__name__, static_url_path='/stark/static')
@@ -108,24 +108,11 @@ def create_app():
return '.' in filename and \
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
@app.route('/upload')
def upload_file2():
return render_template('upload.html')
@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'])
@app.route('/stark/about', methods=['GET'])
def about():
return render_template('about.html')
@app.route('/result/<result_id>', methods=['GET', 'POST'])
@app.route('/stark/result/<result_id>', methods=['GET', 'POST'])
def result(result_id):
if request.method == 'POST':
@@ -167,7 +154,7 @@ def create_app():
displayed_content_dict[TABLE_COLUMNS2DISPLAYED_TABLE_COLUMNS[column]] = v
return render_template('result.html', head_row=displayed_head, content=displayed_content_dict)
@app.route('/', methods=['GET', 'POST'])
@app.route('/stark/', methods=['GET', 'POST'])
# @headers({'Cache-Control': 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0'})
def index():
translations = _translations[get_locale()]
@@ -274,27 +261,30 @@ def create_app():
else:
configs['query'] = None
# handling input
if 'compare_file' in request.files and request.files['compare_file']:
# store file
f = request.files['compare_file']
input_path = os.path.join('media', secure_filename(f.filename))
f.save(input_path)
# handling input
if 'compare_file' in request.files and request.files['compare_file']:
# store file
f = request.files['compare_file']
input_path = os.path.join('media', secure_filename(f.filename))
f.save(input_path)
configs['compare'] = input_path
if 'compare_url' in form and form['compare_url']:
validation['compare_file'] = gettext('Please insert either compare url or file, not both of them.')
validation['compare_url'] = gettext('Please insert either compare url or file, not both of them.')
elif 'compare_url' in form and form['compare_url']:
try:
name = form['compare_url'].split('/')[-1]
input_path = os.path.join('media', name)
response = requests.get(form['compare_url'])
open(input_path, "wb").write(response.content)
configs['compare'] = input_path
if 'compare_url' in form and form['compare_url']:
validation['compare_file'] = gettext('Please insert either compare url or file, not both of them.')
validation['compare_url'] = gettext('Please insert either compare url or file, not both of them.')
elif 'compare_url' in form and form['compare_url']:
try:
name = form['compare_url'].split('/')[-1]
input_path = os.path.join('media', name)
response = requests.get(form['compare_url'])
open(input_path, "wb").write(response.content)
configs['compare'] = input_path
except:
validation['compare_url'] = gettext('Incorrect URL!')
except:
configs['compare'] = None
validation['compare_url'] = gettext('Incorrect URL!')
else:
configs['compare'] = None
configs['sentence_count_file'] = None
configs['detailed_results_file'] = None