Webserver

Questions and comments specific to a particular plugin should go here.
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Webserver

Post by Pako » Sat May 07, 2016 8:28 am

V_J wrote:File "C:\Program Files (x86)\EventGhost\plugins\Webserver\__init__.py", line 3537, in __call__
print "ERROR "+str(e.code)
AttributeError: 'URLError' object has no attribute 'code'
This is apparently a bug that prevents the listing of any error message.
You can fix this by myself for now. Using notepad.exe open the file __init__.py, which is located in the folder EventGhost\plugins\Webserver.
Find the line 3537, and instead of print "ERROR "+str(e.code)" write only print "ERROR "+str(e)".
It is obvious that even then it will not work. However, you should at least have seen an error message in the log.

Pako
You know flattr ? You can Image

V_J
Experienced User
Posts: 165
Joined: Tue Mar 04, 2014 9:00 am

Re: Webserver

Post by V_J » Sat May 07, 2016 9:29 am

Thanks! With the correction, I get the following behaviour:
-
event: (empty)
url: http://ip:port/dev/sps/io/variable/value
username: eventghost
password: (empty)
-
gives
-
Webserver: Send event to another webserver:
The authentication line is badly formed.
-
Putting the username in front of the url as so:
-
event: (empty)
url: http://eventghost@ip:port/dev/sps/io/variable/value
username: (empty)
password: (empty)
-
gives
-
Webserver: Send event to another webserver:
This page isn't protected by authentication.
But we failed for another reason.
ERROR <urlopen error [Errno 11003] getaddrinfo failed>
-
If I omit the username entirely, I get the same error as in the first example.


Jörg

V_J
Experienced User
Posts: 165
Joined: Tue Mar 04, 2014 9:00 am

Re: Webserver

Post by V_J » Sun May 08, 2016 12:24 pm

Googled a bit, and learned that there is an issue with the syntax "http://username:password@website/..."
http://stackoverflow.com/questions/4706 ... -in-python
Could that be the issue in the plugin...?

User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Webserver

Post by Pako » Sun May 08, 2016 4:27 pm

I've done some work on Webserver plugin.
Any errors are corrected, some new actions are added.
I tested it for some time, but it's not enough.
So far, we call it an experimental version.
I ask all users (who use the Webserver plugin) for thorough testing!

Thanks, Pako
Attachments
__init__.py
Experimental version 3.12.1
(228.56 KiB) Downloaded 320 times
You know flattr ? You can Image

Sem;colon
Experienced User
Posts: 609
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: Webserver

Post by Sem;colon » Sun May 15, 2016 8:32 pm

Tested it for some days now, seems to be working fine (I'm not using web sockets and webserver variables though, so I didn't test them, but the old stuff still works fine :) )

mbonaccors
Posts: 16
Joined: Thu Apr 26, 2012 2:46 am

Re: Webserver

Post by mbonaccors » Mon May 16, 2016 12:41 am

hey guys, im curious why is it useful to use their variables feature in webserver? I typically set variables directly as eg.globals.variablenames directly via Python scripts. I can call
these via the website anytime using {{eg.globals.variblenames}}. Is there something that I am missing out on?

I also have a question about calling variables from eventghost via my website using angular.js $http.get and/or $http.post. My goal is for the site to dynamically display images, button states etc. dynamically without having to refresh the page to see the result. This the only downside of my current setup is that the objects don't dynamically refresh so I need to reload the page - which is slow and causes various issues. Is this process possible, and does anyone have any example code they could share for me to learn from?


Thanks for the help!

-Matt B.

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Webserver

Post by krambriw » Mon May 16, 2016 4:07 am

Matt,
You should investigate websockets, that will be the key for you to update single elements in a webpage without doing refresh of the whole. There are several examples in this forum showing code how to use websockets. Try to do a search.

And don't ask the same question in multiple threads!

User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Webserver

Post by Pako » Mon May 16, 2016 10:59 am

I created a simple demo application. You can look here.

Pako
You know flattr ? You can Image

mbonaccors
Posts: 16
Joined: Thu Apr 26, 2012 2:46 am

Re: Webserver

Post by mbonaccors » Tue May 17, 2016 1:37 am

Thanks so much Pako and Krambriw - I will investigate and learn this. Apologies for the double post, will not do that again!

-Matt B.

mbonaccors
Posts: 16
Joined: Thu Apr 26, 2012 2:46 am

Re: Webserver

Post by mbonaccors » Fri May 27, 2016 1:32 pm

Pako and Krambriw, thanks so much for your help! I wanted to give you both an update; I have been studying the demo code that Pako put together, and have been learning more JS.. I got it working this morning! This really breaks open the possibilities, very cool stuff.

User1306
Experienced User
Posts: 53
Joined: Sat Oct 13, 2012 4:37 pm

Re: Webserver

Post by User1306 » Thu Jun 09, 2016 7:36 am

hi

can someone please help me with a small request.
i'm not that good with java-scripting, (just learning it) but what i want to do is simple i would imagine.
is it possible to have a <div> or <iframe> show and hide based on a variable coming from EG?
i'm using the Test files Pako posted (p12) and doing my own editing to them. i would like to have a div or iframe in the webpage that will show (for example) if i send variable with "show" or "hide".
if someone can suggest what the java script code will be that would be great.

thank you in advance

User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Webserver

Post by Pako » Thu Jun 09, 2016 1:53 pm

I did the modification of demonstration program, which I published here.
You can download a modified file index.html.
Here is an example of how you can control it:
showhide.png
showhide.png (6.2 KiB) Viewed 4887 times
Pako
Attachments
index.zip
index.html
(41.4 KiB) Downloaded 211 times
You know flattr ? You can Image

User1306
Experienced User
Posts: 53
Joined: Sat Oct 13, 2012 4:37 pm

Re: Webserver

Post by User1306 » Fri Jun 10, 2016 4:50 pm

Pako Thank you very very much this is exactly what i was looking for
perfect :)

Jabberwock
Posts: 23
Joined: Tue Nov 23, 2010 10:40 pm

Re: Webserver

Post by Jabberwock » Sat Jun 18, 2016 7:57 pm

I wanted to post a bug report (concerning Websockets message), but it turns out that the latest version posted here works perfectly. Now I can use Websockets to control my living-room LEDs with Q Light Controller Plus. Thanks a lot for your work!

Jabberwock
Posts: 23
Joined: Tue Nov 23, 2010 10:40 pm

Re: Webserver

Post by Jabberwock » Sun Jun 19, 2016 8:55 am

Hmm... It seems there is a problem after all... Is the plugin capable of handing a websockets server with a specific URL, e.g.: ws://<ip address>:9999/qlcplusWS ?

EDIT: It is :) I have it working on my testing setup, the problem with the other machine lies elsewhere.
Last edited by Jabberwock on Sun Jun 19, 2016 11:54 am, edited 1 time in total.

Post Reply