4

I've been playing around with Python for some days and I got to the point where I want to put the code of my Python application on the web. Basically the application is all about asking user a question and counting the score based on user's answers [which he types into the application], which later is returned to the user with appropriate comment.

Now I'd like to publish the application to the web. I found Brython but I have problems with getting it to work, being a newbie in Python and a total newbie in JS.

My code in HTML file looks like that:

<html>

        <head>
            <script type="text/javascript" src="brython.js"></script>
        </head>

        <body onload="brython()">

            <script type="text/python" src="filename.py">
            </script>

        </body>

    </html>

Basically, filename.py and brython.js are in the same catalogue as this HTML file. Unfortunately, the code triggers nothing. How should I proceed further? What should I read or do?

Thanks in advance for any help!

Karolina
  • 71
  • 6

2 Answers2

1

Your filename.py should have valid content. The attached example works fine with three files example.html, brython.js & test.py. Python in console vs Brython works slightly different, Start with small examples from that attachment. Happy coding

https://www.dropbox.com/s/kxdhq84bcvunhk9/brython-example.zip?dl=0

nehem
  • 12,775
  • 6
  • 58
  • 84
  • The thing is that `filename.py` works in console :( I'm not sure where is the error but thanks for the tip, I'm looking into your files right now :) – Karolina Dec 11 '15 at 02:53
  • Python in console vs Brython works slightly different, Start with small examples from that attachment. Happy coding. – nehem Dec 11 '15 at 02:57
1

You could start reading the documentation.

While you are developing you could use the debug option on brython function. The errors will appear on the javascript console of you browser.

If you post your filename.py maybe we can help you in a more appropriate way. Also, the paths to files should be correct. If you want to share a code snippet where others can see the problem you could use this jsfiddle.

kikocorreoso
  • 3,999
  • 1
  • 17
  • 26