0

So basically, what I want to do is have a user input some data in an HTML form or something (on client end). Have that data be carried over to a server, where the data is put through some python code and the processed result is sent back to the client. I know, I could use javascript to do this on the user side itself, but I want to experiment a bit and make use of some libraries like tensorflow, matplotlib and so on.

Also, is there some way, you know like Web Assembly to run python code on the client side. Like maybe, send data from server or have it fed by the user, and on some virtual environment type setup and processed ??

Note: I know flask exists and I've tried it, but I can't see the same flexibility as you know regular python code.

Thanks in advance 😊

2 Answers 2

3

There won't come a definite answer to your question because your question is too broad. But maybe this will give you some starting points.

I see you have two questions:

  1. How can I use python server side
  2. How can I use python client side

Question 1: First of all you might know that it makes sense to perform operations on a server and not on a client. For example interacting with a central database. Flask is already lightweight compared to Django which also uses python. If you really want to do a lot on your own you could take a look at websocket or common gateway interface (cgi).

Question 2: This is really not recommended but if you want to play around with WebAssembly and Python a good starting point is PyPyJs: https://github.com/pypyjs/pypyjs!

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot. Just checked out pypyjs. Totally pumped. Will give it a shot.
1

You can use Brython in the browser, it's pretty spiffy. Full dom-manipulation from python; fully compatible with libraries written in pure python. Really neat stuff.

As for the server-side, if you want to keep it full-python, you'll need to use something like flask, bottle, cherrypy, aiohttp,...

If you find yourself struggling; maybe try starting out writing a simple socket-based microservice? You'll then be able to either farm requests out to it from any other server; or incorporate the code in your (python) server code.

Good luck!

2 Comments

Hey! Thanks a lot. I just went through brython. Promising stuff. Will surely work on sockets as that is where I guess I want to go. Right now I want to do a mix of both. Like distributed computing (not technically just an analogy).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.