Skip to content

Commit

Permalink
minor changers
Browse files Browse the repository at this point in the history
  • Loading branch information
Midnight95 committed Oct 3, 2023
1 parent 4286e66 commit f632c49
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
28 changes: 14 additions & 14 deletions page_analyzer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/<id>')
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/<int:id>')
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/<id>/checks')
def check_url(id):
addr = render_url(id=id, table='urls', col='id')[0]['name']
@app.post('/urls/<int:id>/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(
Expand All @@ -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))
3 changes: 3 additions & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
Empty file added tests/test_config.py
Empty file.

0 comments on commit f632c49

Please sign in to comment.