Uncaught ReferenceError: app is not defined, Uncaught SyntaxError: Unexpected token <. Something is missing
<p>Somehow, the button is not defined, even though it is specified by the script. What's missing?</p>

<p>index.html </p>

<pre><code>   $def with (form, text)
    &lt;html&gt;
        &lt;head&gt;
        &lt;title&gt;Reverser&lt;/title&gt;
              &lt;link rel="stylesheet" href="css/master.css"&gt;
        &lt;/head&gt;
        &lt;body&gt;
            &lt;div&gt;
                &lt;input id="str_invert_input" type="text"&gt;
                &lt;button onclick="app.invert()"&gt;Invert&lt;/button&gt;
            &lt;/div&gt;
            &lt;hr&gt;
            &lt;div&gt;
                &lt;h2 id="result"&gt;&lt;/h2&gt;
            &lt;/div&gt;
            &lt;script src="/web/static/js/jquery-1.11.3.min.js" type="text/javascript"&gt;&lt;/script&gt;
            &lt;script src="/web/static/js/main.js" type="text/javascript"&gt;&lt;/script&gt;
        &lt;/body&gt;
    &lt;/html&gt;
</code></pre>

<p>main.js</p>

<pre><code>var app = {
  invert : function(){
    var str = $('#str_invert_input');
    var inputVal = str.val();
    var encoded = encodeURI(inputVal);

    var result = $('#result');

    // Add the web service URL
    $.get( "http://127.0.0.1:8081/"+encoded, function( data ) {

    result.html(data);

    });
  }

}
</code></pre>

<p>As you can see the app seems to have been defined, and called by the script on the index.html.</p>

<p>main.py</p>

<pre><code>import web
from web import form

urls = (
    '/(.*)', 'index',
)

render = web.template.render('C:/Users/A/Desktop/Web/templates')

my_form = form.Form(
                form.Textbox('', class_='textfield', id='textfield'),
                )

class invert:
    def GET(self, invert):
        web.header('Access-Control-Allow-Origin', '*')
        return render.index(form, "String Reverser!")
        #no code yet




app = web.application(urls, globals())

if __name__ == "__main__": 
    app.run()
</code></pre>