summaryrefslogtreecommitdiff
path: root/day7/http_handler.py
diff options
context:
space:
mode:
authorAndrew <saintruler@gmail.com>2019-05-24 18:42:16 +0400
committerAndrew <saintruler@gmail.com>2019-05-24 18:42:16 +0400
commit11979f1e220587198ba05fd3c1f88d4f81195fff (patch)
tree7161944a8935b3574ff6d044d123e9c8d1ed437f /day7/http_handler.py
parent0f0e815ad1b775ff93699b695f290c562c57962f (diff)
Обновлена главная страница, изменен шаблонизатор.
Парсинг HTTP запросов стал более строгим. Сервер заканчивает работу при невалидном HTTP запросе. Начата работа над документацией.
Diffstat (limited to 'day7/http_handler.py')
-rw-r--r--day7/http_handler.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/day7/http_handler.py b/day7/http_handler.py
index e5a551b..4712afe 100644
--- a/day7/http_handler.py
+++ b/day7/http_handler.py
@@ -8,7 +8,7 @@ from config import *
import db
-def log_func(func):
+def log_requests(func):
def wrapper(*args, **kwargs):
address = kwargs['address'] if 'address' in kwargs else args[0]
method = kwargs['method'] if 'method' in kwargs else args[1]
@@ -26,7 +26,7 @@ def log_func(func):
return wrapper
-@log_func
+@log_requests
def process_request(address, method, url, http_ver, headers: dict, query):
if validate_url(url):
try:
@@ -116,7 +116,7 @@ def main(host, port):
connection.close()
del connection
- except KeyboardInterrupt:
+ except (KeyboardInterrupt, ConnectionError):
print('Stopping server...')
try:
@@ -133,5 +133,5 @@ def main(host, port):
if __name__ == '__main__':
- HOST, PORT = ADDR = '0.0.0.0', 4002
+ HOST, PORT = ADDR = '0.0.0.0', 4001
main(HOST, PORT)