mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-01 20:20:10 +00:00
02_HTTPSRV: fixed commandref
git-svn-id: https://svn.fhem.de/fhem/trunk@16874 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
c5de67abaa
commit
6b8dd9007a
@ -37,7 +37,7 @@ HTTPSRV_addExtension($$$$) {
|
|||||||
$data{FWEXT}{$url}{NAME} = $friendlyname;
|
$data{FWEXT}{$url}{NAME} = $friendlyname;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
HTTPSRV_removeExtension($) {
|
HTTPSRV_removeExtension($) {
|
||||||
my ($link)= @_;
|
my ($link)= @_;
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ HTTPSRV_Initialize($) {
|
|||||||
#$hash->{AttrFn} = "HTTPSRV_Attr";
|
#$hash->{AttrFn} = "HTTPSRV_Attr";
|
||||||
$hash->{AttrList} = "directoryindex " .
|
$hash->{AttrList} = "directoryindex " .
|
||||||
"readings";
|
"readings";
|
||||||
$hash->{AttrFn} = "HTTPSRV_Attr";
|
$hash->{AttrFn} = "HTTPSRV_Attr";
|
||||||
#$hash->{SetFn} = "HTTPSRV_Set";
|
#$hash->{SetFn} = "HTTPSRV_Set";
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
@ -92,7 +92,7 @@ HTTPSRV_Define($$) {
|
|||||||
Log3 $name, 3, "$name: new ext defined infix:$infix: dir:$directory:";
|
Log3 $name, 3, "$name: new ext defined infix:$infix: dir:$directory:";
|
||||||
|
|
||||||
HTTPSRV_addExtension($name, "HTTPSRV_CGI", $infix, $friendlyname);
|
HTTPSRV_addExtension($name, "HTTPSRV_CGI", $infix, $friendlyname);
|
||||||
|
|
||||||
$hash->{STATE} = $name;
|
$hash->{STATE} = $name;
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ sub
|
|||||||
HTTPSRV_Attr(@)
|
HTTPSRV_Attr(@)
|
||||||
{
|
{
|
||||||
my ($cmd,$name,$aName,$aVal) = @_;
|
my ($cmd,$name,$aName,$aVal) = @_;
|
||||||
if ($cmd eq "set") {
|
if ($cmd eq "set") {
|
||||||
if ($aName =~ "readings") {
|
if ($aName =~ "readings") {
|
||||||
if ($aVal !~ /^[A-Z_a-z0-9\,]+$/) {
|
if ($aVal !~ /^[A-Z_a-z0-9\,]+$/) {
|
||||||
Log3 $name, 3, "$name: Invalid reading list in attr $name $aName $aVal (only A-Z, a-z, 0-9, _ and , allowed)";
|
Log3 $name, 3, "$name: Invalid reading list in attr $name $aName $aVal (only A-Z, a-z, 0-9, _ and , allowed)";
|
||||||
@ -136,8 +136,8 @@ sub HTTPSRV_CGI() {
|
|||||||
my ($request) = @_; # /$infix/filename
|
my ($request) = @_; # /$infix/filename
|
||||||
|
|
||||||
# Debug "request= $request";
|
# Debug "request= $request";
|
||||||
|
|
||||||
# Match request first without trailing / in the link part
|
# Match request first without trailing / in the link part
|
||||||
if($request =~ m,^(/[^/]+)(/(.*)?)?$,) {
|
if($request =~ m,^(/[^/]+)(/(.*)?)?$,) {
|
||||||
my $link= $1;
|
my $link= $1;
|
||||||
my $filename= $3;
|
my $filename= $3;
|
||||||
@ -148,9 +148,9 @@ sub HTTPSRV_CGI() {
|
|||||||
$link = $link."/";
|
$link = $link."/";
|
||||||
return("text/plain; charset=utf-8", "Illegal request: $request") if(! $data{FWEXT}{$link});
|
return("text/plain; charset=utf-8", "Illegal request: $request") if(! $data{FWEXT}{$link});
|
||||||
}
|
}
|
||||||
|
|
||||||
# get device name
|
# get device name
|
||||||
$name= $data{FWEXT}{$link}{deviceName};
|
$name= $data{FWEXT}{$link}{deviceName};
|
||||||
|
|
||||||
# Debug "link= $link";
|
# Debug "link= $link";
|
||||||
# Debug "filename= $filename";
|
# Debug "filename= $filename";
|
||||||
@ -169,7 +169,7 @@ sub HTTPSRV_CGI() {
|
|||||||
readingsSingleUpdate($defs{$name}, $reading, $value, 1);
|
readingsSingleUpdate($defs{$name}, $reading, $value, 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
# set directory index
|
# set directory index
|
||||||
$filename= AttrVal($name,"directoryindex","index.html") unless($filename);
|
$filename= AttrVal($name,"directoryindex","index.html") unless($filename);
|
||||||
$filename =~ s/\?.*//;
|
$filename =~ s/\?.*//;
|
||||||
@ -191,10 +191,10 @@ sub HTTPSRV_CGI() {
|
|||||||
return("text/plain; charset=utf-8", "Illegal request: $request");
|
return("text/plain; charset=utf-8", "Illegal request: $request");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
####
|
####
|
||||||
@ -213,7 +213,7 @@ sub HTTPSRV_CGI() {
|
|||||||
<a name="HTTPSRV"></a>
|
<a name="HTTPSRV"></a>
|
||||||
<h3>HTTPSRV</h3>
|
<h3>HTTPSRV</h3>
|
||||||
<ul>
|
<ul>
|
||||||
Provides a mini HTTP server plugin for FHEMWEB. It serves files from a given directory.
|
Provides a mini HTTP server plugin for FHEMWEB. It serves files from a given directory.
|
||||||
It optionally accepts a query string to set readings of this device if an attribute allows the given reading<p>
|
It optionally accepts a query string to set readings of this device if an attribute allows the given reading<p>
|
||||||
|
|
||||||
HTTPSRV is an extension to <a href="HTTPSRV">FHEMWEB</a>. You must install FHEMWEB to use HTTPSRV.</p>
|
HTTPSRV is an extension to <a href="HTTPSRV">FHEMWEB</a>. You must install FHEMWEB to use HTTPSRV.</p>
|
||||||
@ -221,7 +221,7 @@ sub HTTPSRV_CGI() {
|
|||||||
<a name="HTTPSRVdefine"></a>
|
<a name="HTTPSRVdefine"></a>
|
||||||
<b>Define</b>
|
<b>Define</b>
|
||||||
<ul>
|
<ul>
|
||||||
<code>define <name> <infix> <directory> <friendlyname></code><br><br>
|
<code>define <name> HTTPSRV <infix> <directory> <friendlyname></code><br><br>
|
||||||
|
|
||||||
Defines the HTTP server. <code><infix></code> is the portion behind the FHEMWEB base URL (usually
|
Defines the HTTP server. <code><infix></code> is the portion behind the FHEMWEB base URL (usually
|
||||||
<code>http://hostname:8083/fhem</code>), <code><directory></code> is the absolute path the
|
<code>http://hostname:8083/fhem</code>), <code><directory></code> is the absolute path the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user