You can write a Python script to run a geoprocessing workflow and publish it as a web tool. The primary method of running a script is to use ArcPy.
Once a customized tool is run successfully, use arcpy functionality to publish it as a web tool. First, create a service definition draft file using either the GeoProcessingSharingDraft class and CreateSharingDraft, or the CreateGPSDDraft function. Then, create a service definition file using the Stage Service tool, and use the Upload Service Definition tool to complete the publishing process.