Skip to content

Commit 3a46871

Browse files
author
Cory Fowler
authored
Merge pull request #5 from berndverst/master
Update IIS web config
2 parents 44e74fe + 191bb3f commit 3a46871

File tree

3 files changed

+108
-9
lines changed

3 files changed

+108
-9
lines changed
Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# ############################################################################
2+
#
3+
# Copyright (c) Microsoft Corporation.
4+
#
5+
# This source code is subject to terms and conditions of the Apache License, Version 2.0. A
6+
# copy of the license can be found in the License.html file at the root of this distribution. If
7+
# you cannot locate the Apache License, Version 2.0, please send an email to
8+
# vspython@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
9+
# by the terms of the Apache License, Version 2.0.
10+
#
11+
# You must not remove this notice, or any other, from this software.
12+
#
13+
# ###########################################################################
14+
115
import datetime
216
import os
317
import sys
@@ -27,6 +41,19 @@ def log(txt):
2741
finally:
2842
f.close()
2943

44+
ptvsd_secret = os.getenv('WSGI_PTVSD_SECRET')
45+
if ptvsd_secret:
46+
log('Enabling ptvsd ...\n')
47+
try:
48+
import ptvsd
49+
try:
50+
ptvsd.enable_attach(ptvsd_secret)
51+
log('ptvsd enabled.\n')
52+
except:
53+
log('ptvsd.enable_attach failed\n')
54+
except ImportError:
55+
log('error importing ptvsd.\n')
56+
3057
def get_wsgi_handler(handler_name):
3158
if not handler_name:
3259
raise Exception('WSGI_ALT_VIRTUALENV_HANDLER env var must be set')
@@ -92,4 +119,4 @@ def get_venv_handler():
92119
log('Getting handler %s\n' % os.getenv('WSGI_ALT_VIRTUALENV_HANDLER'))
93120
handler = get_wsgi_handler(os.getenv('WSGI_ALT_VIRTUALENV_HANDLER'))
94121
log('Got handler: %r\n' % handler)
95-
return handler
122+
return handler

web.2.7.config

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,46 @@
1+
<?xml version="1.0"?>
12
<configuration>
23
<appSettings>
3-
<add key="WSGI_ALT_VIRTUALENV_HANDLER" value="main.app" />
4+
<add key="WSGI_ALT_VIRTUALENV_HANDLER" value="app.wsgi_app" />
45
<add key="WSGI_ALT_VIRTUALENV_ACTIVATE_THIS"
56
value="D:\home\site\wwwroot\env\Scripts\activate_this.py" />
6-
<add key="pythonpath" value="%SystemDrive%\home\site\wwwroot" />
7-
<add key="WSGI_HANDLER" value="virtualenv_proxy.get_virtualenv_handler()" />
7+
<add key="WSGI_HANDLER"
8+
value="ptvs_virtualenv_proxy.get_virtualenv_handler()" />
9+
<add key="PYTHONPATH" value="D:\home\site\wwwroot" />
810
</appSettings>
9-
</configuration>
11+
<system.web>
12+
<compilation debug="true" targetFramework="4.0" />
13+
</system.web>
14+
<system.webServer>
15+
<modules runAllManagedModulesForAllRequests="true" />
16+
<handlers>
17+
<remove name="Python27_via_FastCGI" />
18+
<remove name="Python34_via_FastCGI" />
19+
<add name="Python FastCGI"
20+
path="handler.fcgi"
21+
verb="*"
22+
modules="FastCgiModule"
23+
scriptProcessor="D:\Python27\python.exe|D:\Python27\Scripts\wfastcgi.py"
24+
resourceType="Unspecified"
25+
requireAccess="Script" />
26+
</handlers>
27+
<rewrite>
28+
<rules>
29+
<rule name="Static Files" stopProcessing="true">
30+
<conditions>
31+
<add input="true" pattern="false" />
32+
</conditions>
33+
</rule>
34+
<rule name="Configure Python" stopProcessing="true">
35+
<match url="(.*)" ignoreCase="false" />
36+
<conditions>
37+
<add input="{REQUEST_URI}" pattern="^/static/.*" ignoreCase="true" negate="true" />
38+
</conditions>
39+
<action type="Rewrite"
40+
url="handler.fcgi/{R:1}"
41+
appendQueryString="true" />
42+
</rule>
43+
</rules>
44+
</rewrite>
45+
</system.webServer>
46+
</configuration>

web.3.4.config

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,44 @@
1+
<?xml version="1.0"?>
12
<configuration>
23
<appSettings>
3-
<add key="WSGI_ALT_VIRTUALENV_HANDLER" value="main.app" />
4+
<add key="WSGI_ALT_VIRTUALENV_HANDLER" value="app.wsgi_app" />
45
<add key="WSGI_ALT_VIRTUALENV_ACTIVATE_THIS"
56
value="D:\home\site\wwwroot\env\Scripts\python.exe" />
6-
<add key="pythonpath" value="%SystemDrive%\home\site\wwwroot" />
7-
<add key="WSGI_HANDLER" value="virtualenv_proxy.get_venv_handler()" />
7+
<add key="WSGI_HANDLER"
8+
value="ptvs_virtualenv_proxy.get_venv_handler()" />
9+
<add key="PYTHONPATH" value="D:\home\site\wwwroot" />
810
</appSettings>
9-
</configuration>
11+
<system.web>
12+
<compilation debug="true" targetFramework="4.0" />
13+
</system.web>
14+
<system.webServer>
15+
<modules runAllManagedModulesForAllRequests="true" />
16+
<handlers>
17+
<remove name="Python27_via_FastCGI" />
18+
<remove name="Python34_via_FastCGI" />
19+
<add name="Python FastCGI"
20+
path="handler.fcgi"
21+
verb="*"
22+
modules="FastCgiModule"
23+
scriptProcessor="D:\Python34\python.exe|D:\Python34\Scripts\wfastcgi.py"
24+
resourceType="Unspecified"
25+
requireAccess="Script" />
26+
</handlers>
27+
<rewrite>
28+
<rules>
29+
<rule name="Static Files" stopProcessing="true">
30+
<conditions>
31+
<add input="true" pattern="false" />
32+
</conditions>
33+
</rule>
34+
<rule name="Configure Python" stopProcessing="true">
35+
<match url="(.*)" ignoreCase="false" />
36+
<conditions>
37+
<add input="{REQUEST_URI}" pattern="^/static/.*" ignoreCase="true" negate="true" />
38+
</conditions>
39+
<action type="Rewrite" url="handler.fcgi/{R:1}" appendQueryString="true" />
40+
</rule>
41+
</rules>
42+
</rewrite>
43+
</system.webServer>
44+
</configuration>

0 commit comments

Comments
 (0)