Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Brython entirely client-side?

Tags:

python

brython

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 server that can actually run code on the server side.

Does Brython require server-side code, or can I host a page using it on the cheap with (say) Dropbox?

like image 805
badp Avatar asked Jan 19 '13 20:01

badp


People also ask

Is Python server or client-side?

Server-side code can be written in any number of programming languages — examples of popular server-side web languages include PHP, Python, Ruby, C#, and JavaScript (NodeJS).

Is HTML5 client-side?

In HTML5, two client-side storage facilities have been added: web storage, which includes session and local storage, and database storage. In this article, you will learn about these new client-side storage options and work through some recipes to get you started with storing data locally in the browser.

Is Brython a framework?

There is no framework available in Brython. It may take many years for Brython to be used on client-side. There is a lack of resources to learn Brython, so people are choosing Javascript over Brython.

Is JavaScript a client-side?

Client-side scripting simply means running scripts, such as JavaScript, on the client device, usually within a browser. All kinds of scripts can run on the client side if they are written in JavaScript, because JavaScript is universally supported.


2 Answers

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.

like image 169
Francois Dion Avatar answered Sep 20 '22 21:09

Francois Dion


Brython itself seems to be completely client side, but whether that will be enough really depends on the code you wrote. It is not a full blown Python interpreter and does not have the libraries. You might want a backend to support it or use another client side solution as suggested in the comments.

Given how few real web hosters support Python, I think it is very unlikely that Dropbox would be suitable for this, in case you do need processing on the server as well.

like image 28
Thijs van Dien Avatar answered Sep 23 '22 21:09

Thijs van Dien