Skip to content

Instantly share code, notes, and snippets.

@moyashi
Created August 24, 2015 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moyashi/6089cc93ae25dbcfff56 to your computer and use it in GitHub Desktop.
Save moyashi/6089cc93ae25dbcfff56 to your computer and use it in GitHub Desktop.
#coding: utf-8
import os
import requests
import clipboard
host = "192.168.0.1"
dir = "FlashAir"
fname = "CLIP.TXT"
fpath = "%s/%s" % (dir, fname)
if not os.path.exists(dir):
os.mkdir(dir)
f = open(fpath, "w")
t = clipboard.get().encode("shift-jis").replace("\r", "\r\n")
f.writelines(t)
f.close()
url = "http://%s/upload.cgi" % host
payload = {'UPDIR':'/'}
r = requests.get(url, params=payload)
r.raise_for_status()
files = {'file':(fname, open(fpath,'rb'))}
r = requests.post(url, files=files)
r.raise_for_status()
@moyashi
Copy link
Author

moyashi commented Aug 24, 2015

for Pythonista

@moyashi
Copy link
Author

moyashi commented Aug 24, 2015

flashget.py

import requests
import encodings
import clipboard

host = "192.168.0.1"
fnane = "CLIP.TXT"

c = requests.get("http://%s/%s" % (host, fname)).content
t = unicode(c, 'shift_jis')
t = t.encode("utf-8")
clipboard.set(t.replace("\r\n", "\r"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment