I wrote a program on python that solves simple problems in genetics. I would like to provide access to this program from any device from anywhere. I can write the interface on html / css. Say what will be the layer that will send text from text fields to the program and output what the program displays.
- If the program is interactive, then you can use web socketsists to send data from the client to your program and back (your program is sent to the place of the script with line.upper ()) . - jfs
2 answers
I use bottle.py for such things. This is a very simple web server. Because of its simplicity, it is rarely used: little functionality.
The reverse side of this - it is easy to learn. The link above is hello world, which will be enough for the described task.
If you want to do something more abruptly - I recommend Flask . It is also simple with basic use, but allows you to do much more cool and complex things.
- If the program is interactive, then bottle.py may not be enough. socket.io on the client and
flask-socketioon the server can be more convenient. - jfs - I agree, this option is more flexible, but more difficult for a beginner. I would start with the simplest, but working version and complicate it, if necessary. - Lebedev Ilya
- It's not about flexibility, but whether it will work at all or not. For example, if you want to make a
1/2division, then the result of0.5(float division) is not just "more flexible" —a very different result, which differs from (simpler)1//2 == 0integer division. Yes, float arithmetic can be more difficult for a beginner than arithmetic with integers, but if we need a response of0.5, rather than0then it is necessary to use float division. From the question, it is not clear what the program is (how it communicates with the outside world), so different options may be appropriate. - jfs - Still decided to study Flask - Kirill Losev
It seems to me much easier to rewrite the calculations in javascript.
But if you really want to use exactly Python, then you can try to make a site backend with it. Details here:
https://docs.python.org/2/library/simplehttpserver.html
or on request to google "python as a web server".
In this case, no layer will be needed. Although to add / slightly rewrite the program, most likely, it will still be necessary.