Skip to content

Example of preparing a server environment on the Windows operating system#

Python must be installed on the server and can be downloaded from the python.org official website.

To use IIS (Internet Information Services) as a web server, you need to configure the configuration file web.config so that the IIS service can properly execute Python code. This file is located in the publication folder of your web server.

After installing the interpreter, you should define the HttpPlatform handler in the web.config file. This handler will transfer connections to the standalone Python process.

Example:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
        <handlers>
            <add name="PythonHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
        </handlers>
        <httpPlatform arguments="<Path-to-server-file>\receive_all_with_counter.py.py"
                      processesPerApplication="16"
                      processPath="<Path-to-python>\python.exe"
                      startupTimeLimit="60"
                      stdoutLogEnabled="true"
                      stdoutLogFile="<Path-to-log-file>\python.log">
            <environmentVariables>
                <environmentVariable name="SOME_VARIABLE" value="%SOME_VAR%"/>
            </environmentVariables>
        </httpPlatform>
    </system.webServer>
</configuration>
  • <Path-to-python>\ - the path to the executable file of the Python interpreter
  • <Path-to-server-file>\ - the path to the server executable file (e.g. receive_all_with_counter.py from the example)
  • <Path-to-log-file>\ - the path to the log file

You will also need to open the corresponding port to the external network by setting the firewall settings (Advanced Options -> Rules for incoming connections -> Create Rule -> Rule Type = Port Protocols, Port -> TCP, specify the firewall settings. options -> Rules for incoming connections -> Create Rule -> Rule Type = Port, Protocols and Port -> TCP, specify port, Action -> Allow connection).