Skip to content

Instantly share code, notes, and snippets.

View nkentaro's full-sized avatar

Kentaro Nakamaye nkentaro

View GitHub Profile
@nkentaro
nkentaro / gist:6d28dcc04c88e33492c54117edbf0399
Created February 6, 2018 14:48
Nested dict to nested JSON
from your_own_facility import YourOwnWSService
ws = YourOwnWSService('wss://example.com/WSAPI/')
message = {
"m": 0,
"i": 55,
"n": "YourName",
"o": ""
@nkentaro
nkentaro / django_request_body_as_text.py
Created February 15, 2017 08:55
Retrieve Django's HttpRequest body as text string
def some_view(request):
# HttpRequest.body is byte string
body = request.body.decode('utf-8')
# now body can be handled as a string
.....
@nkentaro
nkentaro / urlcodec.py
Created January 16, 2017 10:27
url encode and decode in python3
import urllib.parse
def urlencode(str):
return urllib.parse.quote(str)
def urldecode(str):
return urllib.parse.unquote(str)
str = '{"name": "Kinkin"}'