The other day I was going to work on a program on my iPad, while sitting next to my laptop. It seemed silly to be writing on an on-screen keyboard when I had a nice keyboard right next to me. Codea has a feature called AirCode, which starts up a web server on the iPad which lets you connect using a computer and write code in a browser and save it to the iPad when you're done. I made something like this using bottle for Pythonista. It doesn't work on my iPad because I have an old version of Pythonista (my iPad can only run iOS 5.1.1), but I have tested it on an iPod with the latest version of Pythonista. If anyone has any suggestions or bug reports, I'd be glad to hear them. Also, if anyone has any idea why it doesn't work on old Pythonista, I'd really appreciate help.
GitHub project here: https://github.com/Ivoah/WebIDE
Yeah, I'm pretty sure OS X has the ability to mount an FTP server like a flash drive natively. Anyways, it should be pretty trivial to make an FTP server in Pythonista, using something like this: python ftp server example
Finally tried this, and I have to say: Very cool idea and impressive implementation! Thanks for sharing!
I wonder if it might be possible to run the server on a background thread, so that it doesn't block the interpreter, and it would be possible to add a "Run" button in the web interface...
Another interesting addition might be Bonjour support via
NSNetServiceor something). I don't really have experience with this, so I don't know how hard that would be, but when using Safari/Mac, you wouldn't have to know the IP address of the iOS device...
@omz From when I've used bonjour, it's really quite cool. The VNC app I use supports it out of the box, and it's really neat. With no prior setup, I can VNC into my macbook from my iPad, and I don't have anything running on the MacBook. They kind of just magically discover each other :)
I've implemented Bonjour support, see my pull request.
This way, "Pythonista WebIDE" automagically shows up in Safari's bookmarks menu when it's running. You may need to enable the Bonjour menu in Safari's Advanced preferences.
Thanks @omz! I've merged your pull request.
This is awesome. Thanks for making this. Now I just need to figure out a way to access it at my school computers.
to run the server on a background thread, so that it doesn't block the interpreter,
I tried to run it under the famous Stash shell.
but Stash only supports python 2, and this is for python 3.
File "...WebIDE.py" with open(fullname, encoding = 'utf-8', mode = 'r') as in_file: # Open the file... TypeError: 'encoding' is an invalid keyword argument for this function
so the problem is function open
after google I added some lines like this:
import sys if sys.version_info.major == 2: import codecs open = codecs.open
now it's t compatible with both python 2 and 3.
another little modification to support utf-8 editing:
change def submit(): # This function will get called for each POST request to / ... f.write(request.forms.get('code').replace('\r', '')) # And dump our code into it
If you use the alternative direct property access request.query.q or forms.q Bottle will give you Unicode strings instead, decoded from the byte version using UTF-8. It's usually best to work with these Unicode strings wherever you can.