-
Notifications
You must be signed in to change notification settings - Fork 0
Microtask 5 #5
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
base: master
Are you sure you want to change the base?
Microtask 5 #5
Conversation
username = request.POST['username'] | ||
try: | ||
if not username: | ||
raise Error("Please enter a username") |
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.
This should be Exception, not Error (I probably remembered wrong). Or you can define your own error type (that has the benefit that you can let other types bubble up to the framework and it will probably show a more developer-friendly error message, with stack traces and whatnot).
url_base = 'https://en.wikipedia.org/w/api.php?' | ||
# Recieved data in json-format | ||
response = requests.get(url_base, params = params) | ||
if response.status_code == 200: |
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.
You can use response.raise_for_status()
and let exception handling deal with non-200 responses.
# Recieved data in json-format | ||
response = requests.get(url_base, params = params) | ||
if response.status_code == 200: | ||
edits_data = json.loads(response.text) |
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.
IIRC you can just call response.json()
@tgr
Sir,
This tool provides view count of last five edits of user in English wiki in current year.
Tool- link
Please review.
Thank you.