Skip to content

Commit af44998

Browse files
committed
fix answer url
1 parent fcef19d commit af44998

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

page_analyzer/app.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ def get_db_connection():
2222
@app.route('/', methods=['GET', 'POST'])
2323
def index():
2424
if request.method == 'POST':
25-
url = request.form['url']
26-
return redirect(url_for('urls', url=url))
25+
url_input = request.form.get('url')
26+
if not validators.url(url_input) or len(url_input) > 255:
27+
flash('Некорректный URL', 'error')
28+
return render_template('index.html'), 422
29+
return redirect(url_for('urls', url=url_input))
2730
return render_template('index.html')
2831

2932
@app.route('/urls', methods=['GET', 'POST'])

0 commit comments

Comments
 (0)