-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lesson 1 Review-01 #1
base: develop
Are you sure you want to change the base?
Conversation
@@ -16,35 +16,45 @@ def send_request(self, method, relative_url, headers=None, params=None, data=Non | |||
result = self.get_request(url, params, headers) | |||
elif method is 'POST': | |||
result = self.post_request(url, data, headers) | |||
elif method is 'PUT': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Добавлена развилка для PUT и DELETE запросов. Для каждого варианта необходимо вызвать соответствующую функцию. Например, для PUT должна быть вызвана функция self.put_request(url, data, headers)
. На данный момент в POST, PUT и DELETE запросах почему-то всегда вызывается одна и та же функция self.post_request(url, data, headers)
.
|
||
def post_request(self, url, data, headers): | ||
return requests.post(url, data=data, headers=headers) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Как следствие из предыдущего коммента - зачем-то созданы 3(!) функции с одинаковым именем.
print(f'HTTP requests to {http.base_url} are successful!') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Поехала табуляция. В Python необходимо уделять особое внимание отступам, так как в данном языке они являются частью синтаксиса.
|
||
|
||
|
||
|
||
if __name__ == '__main__': | ||
http = Http('httpbin.org', 'https') | ||
print(f'Sending HTTP requests to {http.base_url}...') | ||
http.send_request('GET', '/get') | ||
http.send_request('POST', '/post', data={'test_key': 'test_value'}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Отсутствуют вызовы PUT и DELETE запросов.
No description provided.