I recently started exploring the Flask web application framework for Python, but I ran into an issue when trying to deploy the application to Windows Server. My Flask application had a dependency on arcpy, which was available on my local development environment, but not on my server. As you are likely aware, the arcpy package is not available outside of the ArcGIS Pro Python environment, and I ran into quite a few issues with not being able to import and use these libraries. After some some googling, lots of trial and error, and a little help from Esri support, I was able to accomplish this task!
https://mfcallahan.com/2025/02/17/deploying-a-python-flask-application-which-can-import-arcpy-and-th...
Above is the link to my blog post which goes into deep detail on how to accomplish this, but at a high level, the steps needed to accomplish this are:
- Copy app code to server
- Clone the default "arcgispro-py3" environment
- Activate your cloned ArcGIS Pro Python environment in Conda
- Install the flask and wfastcgi dependencies
- Copy file "wfastcgi.py" to the root app folder from the Python site-packages folder
- Create a new application pool
- Set app folder ownership to IIS AppPool
- Add app to FastCGI Server Settings, using the cloned Python env
- Set <handlers> in web.config file