diff options
author | James Taylor <user234683@users.noreply.github.com> | 2018-11-10 21:13:49 -0800 |
---|---|---|
committer | James Taylor <user234683@users.noreply.github.com> | 2018-11-10 21:13:49 -0800 |
commit | 409fea01971c13eae62109f1b8afc01b94960beb (patch) | |
tree | e6ed412333b805ad72603d5b7f2f6824134ab0ce /youtube/youtube.py | |
parent | 717bf210937c757595624348db9389969be9654f (diff) | |
download | yt-local-409fea01971c13eae62109f1b8afc01b94960beb.tar.lz yt-local-409fea01971c13eae62109f1b8afc01b94960beb.tar.xz yt-local-409fea01971c13eae62109f1b8afc01b94960beb.zip |
Use post/redirect/get method to prevent form resubmission for comments
Diffstat (limited to 'youtube/youtube.py')
-rw-r--r-- | youtube/youtube.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/youtube/youtube.py b/youtube/youtube.py index 5451254..0701beb 100644 --- a/youtube/youtube.py +++ b/youtube/youtube.py @@ -95,9 +95,19 @@ def youtube(env, start_response): else: start_response('400 Bad Request', ()) return b'400 Bad Request' + elif path in ("/post_comment", "/comments"): - start_response('200 OK', () ) - return account_functions.post_comment(query_string, fields).encode() + parameters = urllib.parse.parse_qs(query_string) + account_functions.post_comment(parameters, fields) + if 'parent_id' in parameters: + start_response('303 See Other', (('Location', common.URL_ORIGIN + '/comments?' + query_string),) ) + else: + try: + video_id = fields['video_id'][0] + except KeyError: + video_id = parameters['video_id'][0] + start_response('303 See Other', (('Location', common.URL_ORIGIN + '/comments?ctoken=' + comments.make_comment_ctoken(video_id, sort=1)),) ) + return '' else: start_response('404 Not Found', ()) |