Select to view content in your preferred language

Python API to Web Application

3531
3
01-23-2018 07:35 AM
AlexMetzler2
New Contributor

I'm confused on how I would use the Python API for implementation into a web application. For example, with the Javascript API, I write a script that is placed within a html document. When that html document is opened by a user, it populates the application created by the script.

How does one go from the commands in jupyter notebook to a web application?

3 Replies
by Anonymous User
Not applicable

It depends on what you mean by "Web Application". Jupyter itself functions as a web application. When you install the API and run

jupyter notebook

you are running a web application that defaults to port 8888. If you run that command in a folder of notebooks you want to share, you are running a web application that will host those notebooks. Any user can look at that web application, run those notebooks, etc.

For example, https://notebooks.esri.com is a Docker container running on a machine we here at Esri manage. We have it hosting a bunch of example notebooks that any user can run.

Is that what you were asking clarification on? I'm happy to help!

MaherAbdel_Karim
Emerging Contributor

Hi,

actually this is an interesting topic, is there a way to use the javascript api functionality inside the jupyter notebook?

Regards

Maher

0 Kudos
by Anonymous User
Not applicable

When you call these lines inside of a jupyter notebook:

from arcgis.gis import GIS
g = GIS()
g.map()

It is calling an ipywidget jupyter notebook extension that uses the ArcGIS API for Javascript to draw an interactive map in the notebook.  This widget is bundled with the ArcGIS API for Python. So you can use the JS API in that way, you can author your own ipywidget that uses the JS API, you can use cell magics to run other bits of code, etc.

The best option for a "javascript notebook" might be to use the NodeJS Kernel for Jupyter. Just like you write code that uses the ArcGIS API for Python that runs against a Python kernel, you could write code that uses the ArcGIS API for JS that runs against a NodeJS kernel. A Jupyter notebook is not specific to Python, you can author notebooks in any programming language that offers a Jupyter kernel. Disclaimer, I haven't tried any of this, but there do appear to be people out there who do this.