Is Brython entirely client-side?

后端 未结 4 467
温柔的废话
温柔的废话 2021-02-04 04:17

I have a piece of code written in Python. I would like to put that code in a webpage. Brython seems like the simplest way to glue the two things together, but I don\'t have a se

4条回答
  •  被撕碎了的回忆
    2021-02-04 05:09

    Brython is pretty new, and as such is changing rapidly. But, you can use it pretty much anywhere without server side code.

    Some possibilities:

    • run locally, with no server whatsoever. You open the html file in your web browser
    • run on a free web site, without server side access, such as a blog. I use blogger, for example, to demo stuff on my blog, like this interactive breadboard
    • run on a host where you can do stuff server side. This allows you to do Ajax (same domain - check the ajax example in the gallery), and to import libraries that are stored on the server
    • integrate brython with your favorite web framework and templating engine

    Just to be clear, you do not need python on your server. And if you cant link to the brython.js file, you can include the javascript in your web page.

    As for the language support, it does support all the basics and does support classes, list comprehensions, and some less obvious stuff like eval, dis etc. There is a stdout and stderr that default to the web browser console, but can be redirected ( see the console on the brython site for an example of that ). It integrates fine with javascript libraries through JSObject. It has nice HTML5 support.

    The english and spanish documentation are lagging a little behind the french documentation since they are translated from the original in french. They should be back in sync in the next few days. Still, if you look at the console and gallery, it gives you a taste of what is possible.

    There are mailing lists linked on the brython site to provide support if you get stuck.

    I would have provided more examples and links, but I'm new, so I'm limited on the hyperlinks.

提交回复
热议问题