AnsweredAssumed Answered

How to configure a python web tool with file output

Question asked by tsellekaerts on Oct 6, 2020
Latest reply on Oct 8, 2020 by tsellekaerts

I need to publish a python-based web tool which will output an html file.  I have the code working in ArcGIS Pro (2.6), and can publish it successfully. Everything seems to work except the output is not 'returned' to the user. 

 

1. At the start, to ensure it was working, I set the output to be a standard

arcpy.GetParameterAsText(#)

and chose an output file interactively.  In Pro, the script runs and the file is generated correctly.  When published (to a hosting server, 10.8), the script also works as expected but the output is not yet 'returned' to the user.

 

2. So I modified the script to put the output file in the scratch folder:

outputFile = os.path.join(arcpy.env.scratchFolder, "webtool_output.html")

This also works in Pro (although I don't see the output), and publishes and runs successfully in a Portal Web App, but the output isn't returned to the user.

 

3. I found this page:

Geoprocessing service to return a file 

and added

arcpy.SetParameter(0, file.name)

to the end of my code, but this throws an error in ArcGIS Pro (so won't publish as a service.) 

 

4. It seems like the answer to my question should be found here:

Input and output parameters—ArcGIS Pro | Documentation 

I think I would be able to work it out if I could find a functioning example.

Outcomes