About WebPython

WebPython is Python3 interpreter modified to work in Dual mode. The interpreter itself has been modified to work in either "Interpreter" mode to execute conventional scripts from the shell or in "FastCGI" mode where the webserver gets the python3 interpreter to execute the script in FastCGI mode. In the latter case, the Python3 interpreter runs as daemon/process in the background waiting to execute scripts requests from the webserver.

WebPython has been tested with lighttpd server only. Here is a sample configuration.

fastcgi.server = (
  ".py" =>
  (
    "localhost" =>
        ( "socket"    => "/tmp/fcgi-socket",
          "max-procs" => 10,
          "bin-path"  => "/opt/PythonInstall/bin/python3"
        )
  )
)


What about FastCGI module in Python3 ?

The purpose of doing this is to provide a binary like PHP does so that it can be used straight away work in your environment. Also, if you prefer the module you should use that instead of WebPython. No harm done.

What about WSGI , Can't we use that ? 

WSGI is a different technology in comparison to FastCGI, it may be faster but setup is a nightmare to do on conventional WebServers. With WebPython, all  you need to do is add the above configuration in Lighttpd and you are done !

Python3 in comparison to PHP7 is slow, so naturally if you know both PHP and Python3, I would suggest you use PHP7. However, if you have no knowledge of PHP. Then I would suggest you to use Python instead.


Why ?

When you write a PHP code you mix HTML(5)/JavaScript and PHP code into the same file. Its always cluttered, with a sudden introduction of interpreter code between HTML(5) and Javascript. 

Python3 on the other hand was never meant for the web so there is no intermixing of Code between HTML(5) , Javascript and Python3. If you want to send a HTML code, you print it in quotes. Its a whole lot more cleaner and the best programming language when it comes to readability. Granted at the present state of things PHP is a lot faster than Python, that is partly because the interpreter looks for "<?php" and "?>" tags and only parses them as PHP code, the rest of the things it just dumps to the webserver making it a whole lot faster than Python3.


Why WebPython ?

Have you tried setting up Python with a Conventional WebServer in any other mode other than CGI ? Well, its a nightmare and naturally the adoption of Web hosting companies of Python is really really low. Here, the same interpreter works as a command or as a process making it absolutely versatile. If you look at the above mentioned configuration of WebPython you will see that the FastCGI process is the same interpreter.

Reduces Setup Time and Its Faster than Python3 in CGI mode.

Comments

Popular Posts