Skip to content
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

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open

Lesson 1 Review-01 #1

wants to merge 7 commits into from

Conversation

smartiqa
Copy link
Contributor

@smartiqa smartiqa commented Jun 2, 2019

No description provided.

@@ -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':
Copy link
Contributor Author

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)

Copy link
Contributor Author

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!')
Copy link
Contributor Author

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'})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Отсутствуют вызовы PUT и DELETE запросов.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant