2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +00:00

02_HTTPAPI.pm: file read changed

git-svn-id: https://svn.fhem.de/fhem/trunk@26268 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
klaus.schauer 2022-07-29 05:06:32 +00:00
parent 98d9f6738d
commit 1e87097d3b

View File

@ -209,20 +209,12 @@ sub HTTPAPI_CGI($$$) {
sub HTTPAPI_CommandRef($) {
my ($hash) = @_;
my @contents;
my $contents;
my $fileName = $gPath . '/02_HTTPAPI.pm';
if(open(INPUTFILE, $fileName)) {
binmode(INPUTFILE);
@contents = <INPUTFILE>;
close(INPUTFILE);
$contents = join("", @contents);
$contents =~ /\n=begin.html([\s\S]*)\n=end.html/gs;
return($hash, 200, 'close', "text/html; charset=utf-8", encode($encoding, $1));
} else {
return($hash, 404, 'close', "text/plain; charset=utf-8", encode($encoding, "error=404 Not Found, file $fileName not found"));
}
return;
my ($err, @contents) = FileRead($fileName);
return ($hash, 404, 'close', "text/plain; charset=utf-8", encode($encoding, "error=404 Not Found, file $fileName not found")) if ($err);
my $contents = join("\n", @contents);
$contents =~ /\n=begin.html([\s\S]*)\n=end.html/gs;
return ($hash, 200, 'close', "text/html; charset=utf-8", encode($encoding, $1));
}
sub HTTPAPI_Read($) {
@ -388,7 +380,7 @@ sub HTTPAPI_Undef($) {
</ul>
Response:
<ul>
<code>&lt;action&gt;=&lt;response&gt;|&lt;error&gt;=&lt;error message&gt;</code><br>
<code>&lt;action&gt;=&lt;response&gt;|error=&lt;error message&gt;</code><br>
</ul>
</li>
</ul>
@ -404,7 +396,7 @@ sub HTTPAPI_Undef($) {
</ul>
Response:
<ul>
<code>&lt;device&gt;=&lt;cmd&gt;|&lt;error&gt;=&lt;error message&gt;</code><br>
<code>&lt;device&gt;=&lt;cmd&gt;|error=&lt;error message&gt;</code><br>
</ul>
</li>
</ul>
@ -420,7 +412,7 @@ sub HTTPAPI_Undef($) {
</ul>
Response:
<ul>
<code>&lt;reading name&gt;=&lt;val&gt;|&lt;error&gt;=&lt;error message&gt;</code><br>
<code>&lt;reading name&gt;=&lt;val&gt;|error=&lt;error message&gt;</code><br>
</ul>
</li>
<li>API command line for querying a reading<br>
@ -430,7 +422,7 @@ sub HTTPAPI_Undef($) {
</ul>
Response:
<ul>
<code>&lt;reading name&gt;=&lt;val&gt;|&lt;error&gt;=&lt;error message&gt;</code><br>
<code>&lt;reading name&gt;=&lt;val&gt;|error=&lt;error message&gt;</code><br>
</ul>
</li>
<li>API command line for deleting a reading<br>
@ -441,7 +433,7 @@ sub HTTPAPI_Undef($) {
</ul>
Response:
<ul>
<code>&lt;reading name&gt;=|&lt;error&gt;=&lt;error message&gt;</code><br>
<code>&lt;reading name&gt;=|error=&lt;error message&gt;</code><br>
</ul>
</li>
</ul>