<?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 Deploying flask based REST service - works in development mode, crashes when launched by uvicorn. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/deploying-flask-based-rest-service-works-in/m-p/1345804#M69148</link>
    <description>&lt;P&gt;I've developed a REST service that uses flask and runs in flask's development environment without issue. It is installed in a ArcGIS python clone, using the arcgis, arcpy, flask packages. In development mode I see the following. Note it responds properly with a 200 response when queried by a client.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2023-11-03 at 4.34.08 PM.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/85036i6DC9D9ED2CFB4EA8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2023-11-03 at 4.34.08 PM.png" alt="Screen Shot 2023-11-03 at 4.34.08 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I then try running the app using the only production WSGI server available via ArcGIS Pro's Package Manager. I get the following error.&lt;/P&gt;&lt;P&gt;(arcgispro-py3-clone-3) C:\Users\Administrator\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone-3\test_flask&amp;gt; uvicorn app:app --host 0.0.0.0 --port 8002&lt;BR /&gt;starting&lt;BR /&gt;starting&lt;BR /&gt;←[32mINFO←[0m: Started server process [←[36m2728←[0m]&lt;BR /&gt;←[32mINFO←[0m: Waiting for application startup.&lt;BR /&gt;←[32mINFO←[0m: ASGI 'lifespan' protocol appears unsupported.&lt;BR /&gt;←[32mINFO←[0m: Application startup complete.&lt;BR /&gt;←[32mINFO←[0m: Uvicorn running on ←[1mhttp://0.0.0.0:8002←[0m (Press CTRL+C to quit)&lt;/P&gt;&lt;P&gt;At this point the app is running fine. I then send the same request as done earlier with the following response:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;←[31mERROR←[0m: Exception in ASGI application&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "C:\Users\Administrator\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone-3\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 407, in run_asgi&lt;BR /&gt;result = await app( # type: ignore[func-returns-value]&lt;BR /&gt;File "C:\Users\Administrator\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone-3\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 78, in __call__&lt;BR /&gt;return await self.app(scope, receive, send)&lt;BR /&gt;File "C:\Users\Administrator\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone-3\lib\site-packages\uvicorn\middleware\asgi2.py", line 19, in __call__&lt;BR /&gt;instance = self.app(scope)&lt;BR /&gt;TypeError: __call__() missing 1 required positional argument: 'start_response'&lt;BR /&gt;←[32mINFO←[0m: 67.253.80.75:54898 - "←[1mGET / HTTP/1.1←[0m" ←[91m500 Internal Server Error←[0m&lt;/P&gt;&lt;P&gt;The Internal Server error response is immediate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There's lots of info to be found on this error in the context of Django or other environments, but not specific to ArcGIS. I've discovered that in the cloned environment using packages that are not in Package Manager is a non-starter.&lt;/P&gt;&lt;P&gt;Any ideas are most welcome!!&lt;/P&gt;&lt;P&gt;Chuck&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Nov 2023 20:50:26 GMT</pubDate>
    <dc:creator>ChuckBenton</dc:creator>
    <dc:date>2023-11-03T20:50:26Z</dc:date>
    <item>
      <title>Deploying flask based REST service - works in development mode, crashes when launched by uvicorn.</title>
      <link>https://community.esri.com/t5/python-questions/deploying-flask-based-rest-service-works-in/m-p/1345804#M69148</link>
      <description>&lt;P&gt;I've developed a REST service that uses flask and runs in flask's development environment without issue. It is installed in a ArcGIS python clone, using the arcgis, arcpy, flask packages. In development mode I see the following. Note it responds properly with a 200 response when queried by a client.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2023-11-03 at 4.34.08 PM.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/85036i6DC9D9ED2CFB4EA8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2023-11-03 at 4.34.08 PM.png" alt="Screen Shot 2023-11-03 at 4.34.08 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I then try running the app using the only production WSGI server available via ArcGIS Pro's Package Manager. I get the following error.&lt;/P&gt;&lt;P&gt;(arcgispro-py3-clone-3) C:\Users\Administrator\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone-3\test_flask&amp;gt; uvicorn app:app --host 0.0.0.0 --port 8002&lt;BR /&gt;starting&lt;BR /&gt;starting&lt;BR /&gt;←[32mINFO←[0m: Started server process [←[36m2728←[0m]&lt;BR /&gt;←[32mINFO←[0m: Waiting for application startup.&lt;BR /&gt;←[32mINFO←[0m: ASGI 'lifespan' protocol appears unsupported.&lt;BR /&gt;←[32mINFO←[0m: Application startup complete.&lt;BR /&gt;←[32mINFO←[0m: Uvicorn running on ←[1mhttp://0.0.0.0:8002←[0m (Press CTRL+C to quit)&lt;/P&gt;&lt;P&gt;At this point the app is running fine. I then send the same request as done earlier with the following response:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;←[31mERROR←[0m: Exception in ASGI application&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "C:\Users\Administrator\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone-3\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 407, in run_asgi&lt;BR /&gt;result = await app( # type: ignore[func-returns-value]&lt;BR /&gt;File "C:\Users\Administrator\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone-3\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 78, in __call__&lt;BR /&gt;return await self.app(scope, receive, send)&lt;BR /&gt;File "C:\Users\Administrator\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone-3\lib\site-packages\uvicorn\middleware\asgi2.py", line 19, in __call__&lt;BR /&gt;instance = self.app(scope)&lt;BR /&gt;TypeError: __call__() missing 1 required positional argument: 'start_response'&lt;BR /&gt;←[32mINFO←[0m: 67.253.80.75:54898 - "←[1mGET / HTTP/1.1←[0m" ←[91m500 Internal Server Error←[0m&lt;/P&gt;&lt;P&gt;The Internal Server error response is immediate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There's lots of info to be found on this error in the context of Django or other environments, but not specific to ArcGIS. I've discovered that in the cloned environment using packages that are not in Package Manager is a non-starter.&lt;/P&gt;&lt;P&gt;Any ideas are most welcome!!&lt;/P&gt;&lt;P&gt;Chuck&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 20:50:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deploying-flask-based-rest-service-works-in/m-p/1345804#M69148</guid>
      <dc:creator>ChuckBenton</dc:creator>
      <dc:date>2023-11-03T20:50:26Z</dc:date>
    </item>
  </channel>
</rss>

