March 5, 2016 will

What's the quickest way to get the result of your Python app or script online?

There a few options, but I'm going to suggest using the inthing Python module.

First install inthing with PIP. You'll probably know if you need to use sudo or not:

pip install inthing

Now fire up Python, and enter the following (copy and paste each line after the >>> prompt):

>>> from inthing import Stream
>>> stream = Stream.new()

So far so good. We now have a Stream object called stream, with a corresponding live page on the web. We'll have a look at that later, but lets first do something interesting with it. Enter the following function (copy and paste all the text after the >>>):

>>> def mandel(xsize=80, ysize=20, max_iteration=50):
    chars = " .,~:;+*%@##"
    rows = []
    for pixy in xrange(ysize):
        y0 = (float(pixy) / ysize) * 2 - 1
        row = ""
        for pixx in xrange(xsize):
            x0 = (float(pixx) / xsize) * 3 - 2
            x = 0
            y = 0
            iteration = 0
            while (x * x + y * y < 4) and iteration < max_iteration:
                xtemp = x * x - y * y + x0
                y = 2 * x * y + y0
                x = xtemp
                iteration += 1
            row += chars[iteration % 10]
        rows.append(row)
    return "```\n{}\n```\n#mandlebrot".format('\n'.join(rows))

If that pasted correctly, we should have a function that generates the Mandlebrot set in ASCII. Add it to the stream with the following:

>>> stream.text(mandel(), title="Mandlebrot Set!")

Finally, to get the URL of the stream, do this:

>>> print(stream.url)

If you visit that URL, you should see the Mandlebrot set you just generated.

Update: You can see mandlebrot sets as they are posted on the #mandlebrot tag page.

What else can it do?

So inthing.io is still in beta and is actively being worked on, but can already do some interesting things. For instance, you can take screenshots with this:

>>> stream.screenshot(title="This is my work")

More to come...

Use Markdown for formatting
*Italic* **Bold** `inline code` Links to [Google](http://www.google.com) > This is a quote > ```python import this ```
your comment will be previewed here
gravatar
Bruno

(inthing)rochacbruno@vaioubuntu:~/www$ ipython Python 2.7.9 (default, Apr 2 2015, 15:33:21) Type "copyright", "credits" or "license" for more information.

IPython 4.1.2 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details.

In [1]: import inthing

ImportError Traceback (most recent call last) <ipython-input-1-92ff1381fdd5> in <module>() ----> 1 import inthing

/home/rochacbruno/.virtualenvs/inthing/local/lib/python2.7/site-packages/inthing/init.py in <module>() 1 version = "0.1.1" 2 ----> 3 from .stream import Stream

/home/rochacbruno/.virtualenvs/inthing/local/lib/python2.7/site-packages/inthing/stream.py in <module>() 12 from . import errors 13 from . import urls ---> 14 from .rpc import get_interface 15 from .event import Event 16 from .compat import text_type

/home/rochacbruno/.virtualenvs/inthing/local/lib/python2.7/site-packages/inthing/rpc.py in <module>() 5 6 from . import urls ----> 7 from . import jsonrpc 8 9

/home/rochacbruno/.virtualenvs/inthing/local/lib/python2.7/site-packages/inthing/jsonrpc.py in <module>() 6 7 import requests ----> 8 import websocket 9 10

ImportError: No module named websocket

In [2]:

gravatar
Will McGugan

Sorry about that. Can you try an upgrade:

pip install inthing -U