mirror of
https://github.com/dbisu/pico-ducky.git
synced 2025-12-06 02:41:45 +00:00
Add files via upload (#150)
This commit is contained in:
39
webapp.py
39
webapp.py
@@ -102,10 +102,39 @@ def ducky_main(request):
|
|||||||
|
|
||||||
return(response)
|
return(response)
|
||||||
|
|
||||||
def cleanup_text(buffer):
|
_hexdig = '0123456789ABCDEFabcdef'
|
||||||
return_buffer = buffer.replace('+', ' ').replace('%0D%0A', '\n') + '\n'
|
_hextobyte = None
|
||||||
#print(return_buffer)
|
|
||||||
return(return_buffer)
|
def cleanup_text(string):
|
||||||
|
"""unquote('abc%20def') -> b'abc def'."""
|
||||||
|
global _hextobyte
|
||||||
|
|
||||||
|
if not string:
|
||||||
|
return b''
|
||||||
|
|
||||||
|
if isinstance(string, str):
|
||||||
|
string = string.encode('utf-8')
|
||||||
|
|
||||||
|
bits = string.split(b'%')
|
||||||
|
if len(bits) == 1:
|
||||||
|
return string
|
||||||
|
|
||||||
|
res = [bits[0]]
|
||||||
|
append = res.append
|
||||||
|
|
||||||
|
if _hextobyte is None:
|
||||||
|
_hextobyte = {(a + b).encode(): bytes([int(a + b, 16)])
|
||||||
|
for a in _hexdig for b in _hexdig}
|
||||||
|
|
||||||
|
for item in bits[1:]:
|
||||||
|
try:
|
||||||
|
append(_hextobyte[item[:2]])
|
||||||
|
append(item[2:])
|
||||||
|
except KeyError:
|
||||||
|
append(b'%')
|
||||||
|
append(item)
|
||||||
|
|
||||||
|
return b''.join(res).decode().replace('+',' ')
|
||||||
|
|
||||||
web_app = WSGIApp()
|
web_app = WSGIApp()
|
||||||
|
|
||||||
@@ -211,4 +240,4 @@ async def startWebService():
|
|||||||
wsgiServer.start()
|
wsgiServer.start()
|
||||||
while True:
|
while True:
|
||||||
wsgiServer.update_poll()
|
wsgiServer.update_poll()
|
||||||
await asyncio.sleep(0)
|
await asyncio.sleep(0)
|
||||||
Reference in New Issue
Block a user