Q:

Printing Python output in HTML

I have a Python script (which works and outputs correctly when ran) but I am having trouble posting the output to a HTML page. 
No errors are being shown. 
I am new to Python. 
PYTHON
import urllib2

def internet_on():
    try:
        response=urllib2.urlopen('http://64.233.160.94',timeout=1)
        return '<img class="right" src="networkon.png" width="32" height="32">'
    except urllib2.URLError as err: pass
    return '<img class="right" src="networkoff.png" width="32" height="32">'

output = internet_on()
print output

HTML/AJAX/JAVASCRIPT
 <! DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="style.css">
    <script type="text/javascript">
    function wifi() {
        $.ajax ({
            type: "POST",
            urlurl: "file:///home/pi/Desktop/wifi.py",
            data: output,
            dataType: "html",
            success: function(responcew){
                $("wifi").html(responcew);
            }
        });
    }
    </script>
    </head>
    <body>
    <div id="topbar">
        <span id="wifi"></span>
    </div>
    </body>
    </html>

I have also tried:
function wifi() {
    $.ajax ({
        type: "POST",
        urlurl: "file:///home/pi/Desktop/wifi.py",
        data: output,
        dataType: "html"
    });
    document.getElementById('wifi').innerHTML;
}

A:

I don't understand why both times you have urlurl as the url parameter in your ajax post. 
However, even if you corrected that to url, it still won't work.  You can't post to a file, you have to post to a URL that will be handled by some sort of server process.  That could be CGI, but much better to use some kind of (micro-)framework. 
Also, you don't seem to have anything in your JS that would actually call the wifi() function.