Page 4 of 23
Re: Webserver
Posted: Thu Nov 07, 2013 8:53 pm
by Sem;colon
Hi drhyoung,
next time you should maybe ask for a solution to your problem before starting to change the plugin.
I mean, I'm sure you spent some time with the code if it's your first Python experience.
That maybe could have been avoided.
The only thing that is not possible with the plugin as it was using GET is:
Will be in the resulting XML page as ÔÇÿ<egitem name=ÔÇØTestÔÇØ>MyResult</egitem>ÔÇÖ
To be honest I don't see a reason for this using GET, but hey, I guess you see one.
setting a variable with GET could have been done previously with a simple Python script like this:

- 1.PNG (3.52 KiB) Viewed 9252 times
that's inside the script:

- 2.PNG (6.39 KiB) Viewed 9252 times
(just one line!!)
how to use:
http://<ip or hostname>?setVar&<name>&<value>
and you will get:

- 3.PNG (5.33 KiB) Viewed 9252 times
TADAA!! ^^
Re: Webserver
Posted: Fri Nov 08, 2013 5:18 pm
by Sem;colon
Hello everyone,
I made some changes on the plugin again!
What's new?
- added menue entries (plugin configuration) to customize the join strings in the do_POST Enhancement by Sem;colon

- 1.PNG (9.93 KiB) Viewed 9241 times
- improved handling of some returned datatypes in the do_POST Enhancement by Sem;colon
- fixed bug in end_request (length was not always calculated correctly)
@drhyoung: Sorry, I didn't worked your improvements in for several reasons:
#1: GET requests can be cached by a Browser - so retrieving variables with GET is not very reliable.
#2: It's not allowed for plugins to write in eg.globals... see notes for plugin developers.
#3: I can't think of a use case - can you maybe describe one?
Re: Webserver
Posted: Sat Nov 09, 2013 2:55 am
by drhyoung
Hi Sem;colon,
thanks for the feedback.
yes, I am very much the newbie.
I did actually start out researching events and payloads, almost exactly as you have described.
But I couldn't see an easy way to retrieve the values that I had used events and payloads to set.
I have 4 iRule iOS remote apps and have some variables and values that all the remotes need to know about, for example the current TV channel and whether a stereo device is on or off.
The apps are quite dumb when it comes to GET and POST calls.
On searching the web for how to use Webserver to easily do what I wanted, I did find a number of other postings from people who appeared to be looking for something simple also.
When I thought about my requirements, I was thinking, speed (sending and retrieving the states quickly) hence a number of calls in one GET.
I was also looking to record, increment, decrement and capture the setting of channel numbers.
I do see that I would need to add the HTTP header "Cache-Control: no-store" - thanks.
Happy to update the code I've added, or not, as you wish.
Let me know.
Re: Webserver
Posted: Sat Nov 09, 2013 10:51 am
by Sem;colon
Hi drhyoung,
I See, I never used iRule (and maybe never will be)
I have one question: Does it realy need to be that flexible that the Plugin creates the page?
Wouldn't it be OK to write templates with: <egitem name=ÔÇØTestÔÇØ>{{eg.globals.yourVarName}}</egitem> inside ?
Re: Webserver
Posted: Sun Nov 10, 2013 12:55 am
by drhyoung
Hi Sem;colon
I tried creating a page that included {{eg.globals.Testing}} , then setting the variable eg.globals.Testing in EG, then did an http GET on the page I'd created.
It simply displayed " {{eg.globals.Testing}}" to me, ie the variable in the web page wasn't interpreted.
I tried a few other things, because I figured that I must have done something wrong because the {{ }} worked in the original version of the Plugin.
It was then that I thought I needed to have a look at the python. And before I knew it, rather than fixing the {{ }} problem, I thought I might be able to do something more useful for users/configurers of programmable remotes.
But not to worry. It works for me. And it wouldn't even be there for me to use if it wasn't for you, Pako and Bitmonster.
So, thanks.
Re: Webserver
Posted: Sun Nov 10, 2013 1:06 am
by drhyoung
You got me wondering...
If the web page has a filetype of ".htm" then {{ }} does work.
Apologies for the slack testing.
Re: Webserver
Posted: Mon Nov 25, 2013 8:08 pm
by Sem;colon
Hello Everyone,
I get an error when trying to save a specific string with "SetValue" or "SetPersistentValue":

- Unbenannt.png (3.41 KiB) Viewed 9146 times
As you can see the string has "{" and "}" in it, so this is the reason for the error.
Is there a possibility to avoid the error (other then replacing the "{" with something else, I would like to keep the string as it is)?
Sem;colon
Re: Webserver
Posted: Wed Nov 27, 2013 11:37 am
by Pako
I think it is (within EventGhost) quite a common problem.
It occurs in all places where the function
eg.ParseString() is used.
There are several solutions. For example:
1) We can create an alternate function as the function
eg.ParseString(), but more tolerant.
The importance of the brackets {} should be maintained.
2) Or we can create an alternative function, such as the function
eg.ParseString(), but with a different algorithm.
For example, triple braces {{{some expression}}} would serve as the beginning and end of the expression, intended for parsing.
3) We can only handle errors - for example, like this:
Code: Select all
def __call__(self, varname = "", value = "{eg.event.payload}"):
try:
key = eg.ParseString(varname)
except:
eg.PrintError(self.text.err % (str(varname), str(value)))
return
try:
value = eg.ParseString(value)
except (NameError, SyntaxError):
value = value
except:
eg.PrintError(self.text.err % (str(varname), str(value)))
return
self.plugin.SetValue(key, value)
4) ...
In any case, the problem is backwards compatibility.
Which solution will cause the least amount of problems?
I do not know.
Pako
Re: Webserver
Posted: Sun Dec 01, 2013 8:10 pm
by Sem;colon
hmm, what about an extra switch?
e.g. a checkbox in Set...Value for "disable variable recognition" which, if true, bypasses eg.ParseString?
That shouldnÔÇÖt cause any problems with backwards compatibility.
Re: Webserver
Posted: Tue Dec 03, 2013 9:52 am
by Pako
Sem;colon wrote:hmm, what about an extra switch?
Yes, it is a good idea.
I assumed that there are many other solutions (that's why I wrote
4) ...).
In attached file it is already done.
Note: untested
Pako
Re: Webserver
Posted: Mon Dec 23, 2013 8:48 pm
by Sem;colon
Hi Pako,
there was a little bug in line 862 and 863 which caused EG to hang; I fixed it.
EDIT:
I also removed decoding of the return value for the SendEventExt action (could cause problems sometimes)
the code must now be decoded in a script manually (if decoding is needed)
Re: Webserver
Posted: Thu Dec 26, 2013 8:33 am
by Pako
Hi Sem;colon,
I thank you. I do not see how I could screw up like this.
I tried it and it worked. And then I apparently changed it...
Pako
Re: Webserver
Posted: Fri Jan 10, 2014 5:02 pm
by radenblazed
ok so i made a webserver and would like to publish it via my apachi server im currently running... the problem is that the page only works when im using
http://localhost/index.html instead of the no-ip.com dns i have set up... how can i fix this? thank you
Re: Webserver
Posted: Fri Jan 10, 2014 5:06 pm
by radenblazed
I made a webserver using eventghost and would like to publish the page via apachi... the problem is that it only works when i use
http://localhost/index.html instead of the no-ip dns im currently using... is there a way to fix this? thank your
Re: Webserver
Posted: Fri Jan 10, 2014 10:51 pm
by Sem;colon
can you please give us a bit more details what you are trying to do.
Or what you did and what of that works and what doesn't?