mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-02-07 09:18:01 +08:00
ggwave-to-file : add python example
This commit is contained in:
22
examples/ggwave-to-file/ggwave-to-file.py
Normal file
22
examples/ggwave-to-file/ggwave-to-file.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import sys
|
||||
import requests
|
||||
|
||||
def ggwave(message: str, protocolId: int = 1):
|
||||
|
||||
url = 'https://ggwave.ggerganov.com/ggwave-to-file.php'
|
||||
|
||||
params = {
|
||||
'm': message, # message to encode
|
||||
'p': protocolId, # transmission protocol to use
|
||||
}
|
||||
|
||||
response = requests.get(url, params=params)
|
||||
|
||||
if response == '':
|
||||
raise SyntaxError('Request failed')
|
||||
|
||||
return response
|
||||
|
||||
result = ggwave("Hello world!")
|
||||
|
||||
sys.stdout.buffer.write(result.content)
|
||||
Reference in New Issue
Block a user