Guest User

Untitled

a guest
Nov 22nd, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. Assume IIS is installed. My machine already had IIs 8.5.
  2.  
  3. Install Python
  4. ==============
  5.  
  6. 1. Download web installer (Python 3.6.3).
  7. 2. Run as Administrator.
  8. 3. Select custom installation for all users.
  9. 4. Choose install directory such that there are no white spaces in the path. Not sure if it needs to be done. Just being cautious.
  10. 5. Check the box for "Add Python 3.6 to PATH".
  11.  
  12. Install wfastcgi and others
  13. ===========================
  14.  
  15. 1. Open Windows Powershell as Adminstrator.
  16. 2. Run: pip install wfastcgi
  17. 3. Run: pip install flask
  18.  
  19. Setting up Website
  20. ==================
  21.  
  22. 1. On the powershell, run: wfastcgi-enable
  23. It will produce configuration related output. Example:
  24. """
  25. Applied configuration changes to section "system.webserver/fastcgi" for "MACHINE/WEBROOT/APPHOST" at configuration commit path "MACHINE/WEBROOT/APPHOST".
  26. "c:\python36\python.exe|c:\python36\lib\site-packages\wfastcgi.py" can now be used as a FastCGI script processor.
  27. """
  28. 2. Run IIS as administrator.
  29. 3. Go to Connections and expand the tree.
  30. 4. Select "Sites".
  31. 5. Select "Add Website" under Actions panel on the right of the window.
  32. 6. A new window will pop up titled "Add Website". Fill in the necessary info: Site name, Directory containing the website content, IP address and port (I entered 5000).
  33. Since I want to simply run it on local host, IP address can be left as "All unassigned".
  34. 7. The Physical Path you specified in Add Website contains the following files (barebones):
  35. a. web.config: contains web configuration. It has the following content:
  36. """
  37. <?xml version="1.0" encoding="utf-8"?>
  38. <configuration>
  39. <system.webServer>
  40. <handlers>
  41. <remove name="Python27_via_FastCGI" />
  42. <remove name="Python34_via_FastCGI" />
  43. <add name="Python FastCGI"
  44. path="*"
  45. verb="*"
  46. modules="FastCgiModule"
  47. scriptProcessor="C:\Python36\python.exe|C:\Python36\Lib\site-packages\wfastcgi.py"
  48.  
  49. resourceType="Unspecified"
  50. requireAccess="Script" />
  51. </handlers>
  52. </system.webServer>
  53. <appSettings>
  54. <!-- Required settings -->
  55. <add key="WSGI_HANDLER" value="myapp.app" />
  56. <add key="PYTHONPATH" value="C:\inetpub\wwwroot\stealth" />
  57. </appSettings>
  58. </configuration>
  59. """
  60.  
  61. b. myapp.py: contains Flask applicatioh
  62. """
  63. from flask import Flask
  64. app = Flask(__name__)
  65.  
  66. @app.route("/hello")
  67. def hello():
  68. return "Hello Stealth!"
  69. """
  70.  
  71. 8. You might have to restart the Server and the website after configuration changes. Option will be under Actions on the right.
  72.  
  73. 8. If you select the root node, you'll see a bunch of configuration features. We are interested in FastCGI Settings and Handler Mappings.
  74. a. Under FastCGI settings, I have the following:
  75. """
  76. Full Path | Arguments
  77. c:\python36\python.exe | c:\python36\lib\site-packages\wfastcgi.py
  78. c:\Program Files\PHP\php-cgi.exe
  79. """
  80. b. Under Handler Mappings, you'll see different names. Based on web.config, you'll see "Python FastCGI".
  81.  
  82. 10. You can now enter "localhost:5000" into the browser.
Add Comment
Please, Sign In to add comment