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<SPAN class="">.</SPAN>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")<SPAN class=""></SPAN>
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<SPAN class="">.</SPAN>SetParameter<SPAN class="">(</SPAN><SPAN class="">0</SPAN><SPAN class="">,</SPAN> file<SPAN class="">.</SPAN>name<SPAN class="">)</SPAN>
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.