Thursday, November 13, 2025

Python learn

 

Change directory path:

#STATIC_URL = 'static/' #default
STATIC_URL = 'pydjango/static/' # ash.sh changed for sub site path url xyz.com/pydjango

Default URL pattern:
urlpatterns = [
    path('pydjango/admin/', admin.site.urls),
    path('pydjango/', include('aimsapi.urls'))
]


Other added APP/module URL pattern:
urlpatterns=[
    # path('pydjango/', views.getData),
    # path('pydjango/admin', admin.site.urls),
    # path('pydjango/gettable', views.getTable),
   
    path('', views.getData),
    path('admin', admin.site.urls),
    path('gettable', views.getTable),
]


---------IIS Settings-------
IIS application level
1. Select IIS Root(Machine name select, available above Application Pools)
2. Right side icon select IIS. FastCGI Settings
    Add "...../python.exe" in full path and Argument : "...../site-packages/wfastcgi.py"
3. Create site/subsite for python
4. Select site/subsite => IIS. Handler Mapping.
5. Add Add Module Mapping from Action(Right section)
    Request Path: *
    Module: FastCgiModule
    Executable (Optional) (concat with Pipe | operator ) :
"...../python.exe|...../site-packages/wfastcgi.py"

Web config file- generated by IIS.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <appSettings>
    <!-- Required settings -->
    <add key="WSGI_HANDLER" value="django.core.wsgi.get_wsgi_application()" /> <!-- django.core.wsgi.get_wsgi_application()" /> -->
    <!-- Your django path -->
    <add key="PYTHONPATH" value="C:\pythonProject\aims" />
    <!-- Your djangoname.settings -->
    <add key="DJANGO_SETTINGS_MODULE" value="aims.settings" />
  </appSettings>
    <system.webServer>
    <!-- <validation validateIntegratedModeConfiguration="false" /> -->
    <!-- <modules runAllManagedModulesForAllRequests="true" /> -->
    <!-- <modules> -->
      <!-- <remove name="UrlRoutingModule-4.0" /> -->
      <!-- <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" /> -->
    <!-- </modules> -->
        <handlers>
            <remove name="pydjango1" />
            <add name="pydjango1" path="*" verb="*" modules="FastCgiModule" scriptProcessor="C:\python313\python.exe|C:\python313\Lib\site-packages\wfastcgi.py" resourceType="Unspecified" />
      <!-- <remove name="ExtensionlessUrlHandler-Integrated-4.0" /> -->
            <!-- <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" /> -->
       
       
        </handlers>
    </system.webServer>
</configuration>

No comments:

Post a Comment