<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic arcpy from a web page in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-from-a-web-page/m-p/422140#M33178</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, we're constantly exporting data out of our database. We have python scripts that accept parameters and then export and zip up the shapefiles files. From our dashboard, I'd like to put a form where we could select a type and then hit a button, this would then pass the parameter to my python script and create the shapefile for download.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why I can program in JS, Python, PHP and Node, I have not been able to get the python working on our server. I know there is Django,&amp;nbsp;Flask, and others, but I'm not sure which one would be the best choice to work with ArcPy.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I noticed the documentation is also all over the place, is there a cookbook or instructions that demonstrate this concept? I found the thread&amp;nbsp;&lt;SPAN style="font-size: 11.0pt;"&gt;Exposing-Arcpy-Python-Script-to-Web but that was 8 years ago, anything newer and more complete?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 01 May 2019 19:59:52 GMT</pubDate>
    <dc:creator>BillChappell</dc:creator>
    <dc:date>2019-05-01T19:59:52Z</dc:date>
    <item>
      <title>arcpy from a web page</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-from-a-web-page/m-p/422140#M33178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, we're constantly exporting data out of our database. We have python scripts that accept parameters and then export and zip up the shapefiles files. From our dashboard, I'd like to put a form where we could select a type and then hit a button, this would then pass the parameter to my python script and create the shapefile for download.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why I can program in JS, Python, PHP and Node, I have not been able to get the python working on our server. I know there is Django,&amp;nbsp;Flask, and others, but I'm not sure which one would be the best choice to work with ArcPy.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I noticed the documentation is also all over the place, is there a cookbook or instructions that demonstrate this concept? I found the thread&amp;nbsp;&lt;SPAN style="font-size: 11.0pt;"&gt;Exposing-Arcpy-Python-Script-to-Web but that was 8 years ago, anything newer and more complete?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 May 2019 19:59:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-from-a-web-page/m-p/422140#M33178</guid>
      <dc:creator>BillChappell</dc:creator>
      <dc:date>2019-05-01T19:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy from a web page</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-from-a-web-page/m-p/422141#M33179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Figured it out. You can set up an ISAPI handler to pass requests to py files to the python executable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Like step 7 here: &lt;A href="https://stackoverflow.com/questions/6823316/python-on-iis-how"&gt;https://stackoverflow.com/questions/6823316/python-on-iis-how&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This worked for me, and since the site is internal and not heavily used, and I'm still prototyping a solution, I was able to avoid installing a larger framework.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After following the instructions I have a virtual folder called py, so I created a simple python file and placed it into this folder.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I called it helloworld.py just to test it. Its contents.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------helloworld.py script --------------------------&lt;/P&gt;&lt;P&gt;print('Content-Type: text/plain')&lt;/P&gt;&lt;P&gt;print('')&lt;/P&gt;&lt;P&gt;print('Hello, world!')&lt;/P&gt;&lt;P&gt;print('')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import os, sys&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;GET={}&lt;/P&gt;&lt;P&gt;args=os.getenv("QUERY_STRING").split('&amp;amp;')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for arg in args:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; t=arg.split('=')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(t)&amp;gt;1: k,v=arg.split('='); GET&lt;K&gt;=v&lt;/K&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;x = GET.get('user_name')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;print(x)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------&lt;/P&gt;&lt;P&gt;Next, I opened a browser and typed:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://localhost/py/helloworld.py?user_name=Bill"&gt;http://localhost/py/helloworld.py?user_name=Bill&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The page responded:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;Hello, world!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;Bill&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At this point, I have a python script on a web server that I can call by a url, and it runs. Next stop to create a webpage, that has a select (picklist) and a button, when pressed, fires off a ajax get to my script and have my script read the parameter and run. But that's just JavaScript.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2019 16:17:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-from-a-web-page/m-p/422141#M33179</guid>
      <dc:creator>BillChappell</dc:creator>
      <dc:date>2019-05-02T16:17:08Z</dc:date>
    </item>
  </channel>
</rss>

