diff --git a/README.md b/README.md index 7a7e9fc..e4e565f 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,4 @@ [![Github Actions Status](https://github.com/Midnight95/python-project-83/workflows/Python%20CI/badge.svg)](https://github.com/Midnight95/python-project-83/actions) [![Maintainability](https://api.codeclimate.com/v1/badges/a35829300219c07f6809/maintainability)](https://codeclimate.com/github/Midnight95/python-project-83/maintainability) +You can check project [here](http://granovskydev.ru/) \ No newline at end of file diff --git a/page_analyzer/app.py b/page_analyzer/app.py index 30c6f30..44e48d9 100644 --- a/page_analyzer/app.py +++ b/page_analyzer/app.py @@ -99,32 +99,32 @@ def post_urls(): else: flash('Страница успешно добавлена', 'success') urls = get_url_config(data) - id = db.insert( + url_id = db.insert( table='urls', cols=urls.keys(), data=urls.values() ) - return redirect(url_for('url_info', id=id)) + return redirect(url_for('url_info', id=url_id)) -@app.get('/urls/') -def url_info(id): - site = render_url(id=id, table='urls', col='id')[0] - checks = render_url(id=id, table='urls_checks', col='url_id') +@app.get('/urls/') +def url_info(_id: int): + site = render_url(id=_id, table='urls', col='id')[0] + checks = render_url(id=_id, table='urls_checks', col='url_id') return render_template('urls_id.html', site=site, checks=checks) -@app.post('/urls//checks') -def check_url(id): - addr = render_url(id=id, table='urls', col='id')[0]['name'] +@app.post('/urls//checks') +def check_url(_id: int): + addr = render_url(id=_id, table='urls', col='id')[0]['name'] try: - page = requests.get(addr, timeout=5) - page.raise_for_status() + _request = requests.get(addr, timeout=5) + _request.raise_for_status() except requests.RequestException: flash('Произошла ошибка при проверке', 'error') - return redirect(url_for('url_info', id=id)) + return redirect(url_for('url_info', id=_id)) - checks = get_urls_checks(page, id) + checks = get_urls_checks(_request, _id) with Database(db_url) as db: db.insert( @@ -134,4 +134,4 @@ def check_url(id): ) flash('Страница успешно проверена', 'success') - return redirect(url_for('url_info', id=id)) + return redirect(url_for('url_info', id=_id)) diff --git a/tests/test_app.py b/tests/test_app.py index 2f3be29..b601ee0 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -1,5 +1,8 @@ def test_request_example(client): + """ + Test if the client is running + """ response = client.get("/") string = "Анализатор страниц" bytes_data = string.encode('utf-8') diff --git a/tests/test_config.py b/tests/test_config.py new file mode 100644 index 0000000..e69de29