david_1234
Posts: 328
Joined: Mon Jan 01, 2018 2:14 pm

Create a simple web page on apache2 showing sensor ?

Thu Dec 26, 2019 3:07 pm

Hello ,
I want to know if I can do this:
I have a working PI that run zonminder using apache2 server
I understand I can create antoher webpage on the server called tempurture.html(for example)
so I wil be able to enter
http://10.0.0.100/tempurture.html - to see my temp sensor
http://10.0.0.100/zm - to see the zonminder server

it it ture?

if so -
how do I do this? (I don't know php al all , I know basic html)
can I run a pyhton code to read the data (something I have now) and then post it on the html?
I don't need it to log (for the moment)
just show time + temp refresh every 1 second

I don't want to use another server - because I want everyhitng to be at the same port
and if it will work - I want to add a link at zonminder login to to see the temperture
how can I do this ?



I thought about it
and maybe simpler will be to add the code to the login page of the zonminder ?

Code: Select all

<?php
xhtmlHeaders(__FILE__, translate('Login'));
?>
<body>
<?php echo getNavBarHTML(); ?>
        <div class="container">
                <form class="center-block" name="loginForm" id="loginForm" method="post" action="?">
                        <input type="hidden" name="action" value="login"/>
                        <input type="hidden" name="view" value="login"/>
                        <input type="hidden" name="postLoginQuery" value="<?php echo isset($_SERVER['QUERY_STRING']) ? htmlspecialchars($_SERVER['QUERY_STRING']) : ''?>">

                        <div id="loginError" class="hidden alarm" role="alert">
                                <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
                                Invalid username or password.
                        </div>

                        <div id="loginform">

        <h1><i class="material-icons md-36">account_circle</i> <?php echo validHtmlStr(ZM_WEB_TITLE) . ' ' . translate('Login') ?></h1>
        
                                <label for="inputUsername" class="sr-only"><?php echo translate('Username') ?></label>
                                <input type="text" id="inputUsername" name="username" class="form-control" autocapitalize="none" placeholder="Username" required autofocus autocomplete="username"/>
        
                                <label for="inputPassword" class="sr-only"><?php echo translate('Password') ?></label>
                                <input type="password" id="inputPassword" name="password" class="form-control" placeholder="Password" required autocomplete="current-password"/>
        
                                <?php
                                if (defined('ZM_OPT_USE_GOOG_RECAPTCHA') 
                                && defined('ZM_OPT_GOOG_RECAPTCHA_SITEKEY') 
                                && defined('ZM_OPT_GOOG_RECAPTCHA_SECRETKEY')
                                && ZM_OPT_USE_GOOG_RECAPTCHA && ZM_OPT_GOOG_RECAPTCHA_SITEKEY && ZM_OPT_GOOG_RECAPTCHA_SECRETKEY)
                                {
                                echo '<div class="g-recaptcha" data-sitekey="'.ZM_OPT_GOOG_RECAPTCHA_SITEKEY.'"></div>';
                                } ?>
        
                                <button class="btn btn-lg btn-primary btn-block" type="submit"><?php echo translate('Login') ?></button>

                        </div>
                </form>
        </div>
</body>

*****---->>> add here the code for reading dht temperture sensor
</html>
Thanks ,

Return to “General discussion”