Can Indigo web server host a python created text file?

Posted on
Thu Apr 04, 2019 8:00 pm
russg offline
Posts: 46
Joined: Oct 02, 2014

Can Indigo web server host a python created text file?

Hi All,
I'm trying to configure Siri/Indigo so that I can ask Siri a question, and she will respond by reading the contents of a text or http file to me. For example, I could ask Siri on my Apple Watch 'which windows are open?' and she would respond 'the bedroom and office windows are open'.

I can configure Siri to respond to defined questions by reading the contents of a URL using the Mac application 'Shortcuts'. (there is a sample in the Shortcuts Gallery under 'On the Interweb' named 'Speak Body of Article' that will get the text from a web page and speak it). So, if I can create a file that the Indigo web server will host, I can get Siri to read it.

My thoughts on this is that when specific events happen (like a window sensor changes state) I would use python to create a short text string (which is the 'answer' to the specific question) and save it to a file the Indigo web server can host. Alternatively, I could populate an indigo variable with the string and have a control page with only that variable on it (assuming there is no short limitation to the size of Indigo variables)

This isn't a two way conversation with Siri, but it would be a good way to get Indigo specific information through Siri for a limited number of frequently asked questions.

While I can (and do) use HomeKit Buddy to ask about specific devices, I haven't figured out how to use the HK Buddy to publish an Indigo variable containing free form text to HomeKit for Siri to speak. It appears only to publish device states. (If I'm wrong, please correct me).

So, questions:

1. Can I use the Indigo web server to publish simple text or html files to an external web request? If so, where should the files be located so the web server can see them?

2. Would it make more sense to install the standard Mac Apache web server on my Indigo machine and just use it? Will this create problems with my Indigo system (I've never tried to run 2 web servers on the same physical machine, and I'm not sure it is possible with a single network adapter and IP address for the machine.)

Or is there a better way all together to do this?

thanks for any thoughts!
-russg

Posted on
Fri Apr 05, 2019 6:02 am
DaveL17 offline
User avatar
Posts: 6751
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Can Indigo web server host a python created text file?

russg wrote:
So, questions:

1. Can I use the Indigo web server to publish simple text or html files to an external web request? If so, where should the files be located so the web server can see them?

2. Would it make more sense to install the standard Mac Apache web server on my Indigo machine and just use it? Will this create problems with my Indigo system (I've never tried to run 2 web servers on the same physical machine, and I'm not sure it is possible with a single network adapter and IP address for the machine.)

Neat idea!

With respect to (1), Indigo has a public folder within the web server tree that should work for this purpose. I believe it was added with Indigo 7.0 (I may not have that exactly right, but it's there with Indigo 7.2). There should be a readme.txt file in this folder:
Code: Select all
/Volumes/Macintosh HD-1/Library/Application Support/Perceptive Automation/Indigo 7.2/IndigoWebServer/public/README.txt

With respect to (2), in theory it should work, but I'm guessing that they would each have to serve on different ports which could make reaching them both with Siri a challenge.

Hopefully, (1) will work for you.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Fri Apr 05, 2019 8:49 am
jay (support) offline
Site Admin
User avatar
Posts: 18212
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Can Indigo web server host a python created text file?

Yeah, that is an interesting idea. I'd use the public folder mentioned by DaveL. In your Python script, you can safely construct the path (so that it's Indigo version agnostic) thusly:

Code: Select all
public_dir = "{}/IndigoWebServer/public/".format(indigo.server.getInstallFolderPath())


Or you can construct the full file path:

Code: Select all
file_path = "{}/IndigoWebServer/public/{}".format(indigo.server.getInstallFolderPath(), "SomeFile.txt")

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests