How do I call a Python script from a html button ?

12477
15
Jump to solution
04-08-2015 11:31 AM
JulieK
by
Occasional Contributor

If I have a web page  form with 'submit' on this simple Javascript API sample, how would I call the Python script on clicking the submit button? any thoughts or ideas?

0 Kudos
1 Solution

Accepted Solutions
TomSellsted
MVP Regular Contributor

Julie,

Yes, you are on the right path.  The parameters you are filling in have to be tied to the logic you will use to do the analysis you are trying to run.  Otherwise they are just parameters. 

If you are trying to run it in a web browser, you will need to publish the script to ArcGIS Server to be able to access it from the web. 

Regards,

Tom

View solution in original post

15 Replies
TomSellsted
MVP Regular Contributor

Julie,

You could publish your python script as a geoprocessing service on your ArcGIS Server.

Regards,

Tom

0 Kudos
JulieK
by
Occasional Contributor

Good idea Tom, I will give that a try.

You did that with your ibus app right?

Thanks!!

0 Kudos
TomSellsted
MVP Regular Contributor

Julie,

The iBus app used queries to map services of feature classes.  But I do have another app the calls a geoprocessing script.  The python geoprocessing script creates a parcel map PDF when a link or button is clicked for the related parcel being displayed.

Regards,

Tom

JulieK
by
Occasional Contributor

Hi Tom,

Please guide me through this.

I am using ArcGIS 10.2 and

- At the desired location, I created a new toolbox in ArcCatalog.

-Right clicked the toolbox and Added a python script.

-Pointed it to my python script.

-Created two parameter values

Am I in the right path?

My python script has a function that takes two parameters

def formInfo(Name, activeMile):

Now, when I run the toolbox I created, it let me fill two parameters but it doesn't look like it is passing it to the script. The tool gives the message that it ran successfully but it doesn't look like my script  with the parameter.

In 10.2 , there is also an option to create a new 'Python Toolbox' should I be using this? any thoughts?

appreciate your help!!

0 Kudos
TomSellsted
MVP Regular Contributor

Julie,

Yes, you are on the right path.  The parameters you are filling in have to be tied to the logic you will use to do the analysis you are trying to run.  Otherwise they are just parameters. 

If you are trying to run it in a web browser, you will need to publish the script to ArcGIS Server to be able to access it from the web. 

Regards,

Tom

View solution in original post

JulieK
by
Occasional Contributor

should I be doing this?

ArcGIS Help 10.1

0 Kudos
JulieK
by
Occasional Contributor

Tom,

That helped!! I have tied the parameters with the logic....phew.

next will get to publishing it to the server.

0 Kudos
TomSellsted
MVP Regular Contributor

Julie,

Excellent!  I should have put a link for you about retrieving the parameters in the last message.

Regards,

Tom

0 Kudos
JulieK
by
Occasional Contributor

Hey Tom,

I am using a tool called arcREST( Esri/ArcREST at October2014v1.0Final · GitHub ) in my Python script.

On the ArcGIS Server,

-     we installed arcREST tool

-     The script ran successfully.

-     Created a Toolbox and added the Python script.

-     The toolbox ran successfully

-     Created a geoprocessing service

-     Gives error saying "no module named arcrest Failed to execute"

-     Based on this link , tried using sys.path.append

-     Still the same error. "no module named arcrest Failed to execute"

Any thoughts ? idea ?