In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail what is the method and principle of Python web publishing on IIS. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
There are two ways to publish Pythonweb applications using iis. This article introduces the specific implementation of these two ways:
Configure the HttpPlatform program
The HttpPlatform module passes the socket connection directly to a separate Python process. With this delivery, you can run any Web server as needed, but you need a startup script to run the local Web server. Specify the script in the element of web.config, where the processPath attribute points to the Python interpreter of the site extension, and the arguments attribute points to the script and any parameters you want to provide
The HTTP_PLATFORM_PORT environment variable shown here contains the port that the local server uses to listen for connections from localhost.
Configure FastCGI handlers
FastCGI is an interface that works at the request level. IIS receives incoming connections and forwards each request to a WSGI application running in one or more persistent Python processes.
To use the wfastcgi package, install and configure it first, as described in pypi.org/project/wfastcgi/.
Next, modify the applied web.config file to add the full path to python.exe and wfastcgi.py in the PythonHandler key.
Modify the PythonHandler entry in web.config so that the path is the same as the Python installation location.
In the web.config section, add keys for WSGI_HANDLER, WSGI_LOG (optional), and PYTHONPATH
The value of PYTHONPATH can be expanded freely, but it must include the root directory of your application. It extends sys.path, and you can find the package of import under this path.
WSGI_HANDLER must point to WSGI applications that can be imported from your application. There are some differences in this value for different frameworks. Here are some examples.
1.Bottle: make sure app.wsgi_app is followed by parentheses, as shown below. This operation is required because the object is a function, not a variable:
< !--Bottleappsonly--> < addkey="WSGI_HANDLER"value="app.wsgi_app()"/>2.Flask: change the WSGI_HANDLER value to
.app, where matches the project name. You can find the exact identifier by looking at the fromimportapp statement in runserver.py. For example, if the project is named "FlaskAzurePublishExample", the entry looks like this:
< !--Flaskappsonly:changetheprojectnametomatchyourapp--> < addkey="WSGI_HANDLER"value="flask_iis_example.app"/>3.Django: for the Django project, you need to make two changes to "web.config". First, change the WSGI_ handle value to django.core.wsgi.get_wsgi_application () (the object is in the wsgi.py file):
< !--Djangoappsonly--> < addkey="WSGI_HANDLER"value="django.core.wsgi.get_wsgi_application()"/>Second, add the following entry under the WSGI_HANDLER entry and replace DjangoAzurePublishExample with the project name:
< addkey="DJANGO_SETTINGS_MODULE"value="django_iis_example.settings"/>WSGI_LOG is optional, but it is recommended to log when debugging the application.
This is the end of what is the method and principle of publishing Python web on IIS. I hope the above content can be of some help to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.