Small web service to power off or reboot remotely Linux based PC like Orange Pi or Raspberry Pi PC also it works on x86 based PCs.
Compiled program can be run by command sudo ./SZ_WPowerM

Code of project

import os
from bottle import route, get, post, run, template



@post('/power')
def power():
	os.system('shutdown -h now')
@post('/restart')
def reboot():
	os.system('reboot')
@route('/')
def index():
	return template('''<!DOCTYPE html>
<html>
<head>
<title>SZ_WPowerR</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
function power(){
var link = window.location.href + "power";
var xhttp = new XMLHttpRequest();
xhttp.open("POST", link);
xhttp.send();
}
function restart(){
var link = window.location.href + "restart";
var xhttp = new XMLHttpRequest();
xhttp.open("POST", link);
xhttp.send();
}
</script>
<style>
a:hover{
color: #5c6847;
}
a{
color: #062b00;
text-decoration: none;
}
.footer {
    position: fixed;
    bottom: 0;
    right: 15px;
}
.center {
  margin: 0;
  position: absolute;
  top: 50%;
  left: 50%;
  -ms-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
}
.button {
  background-color: #062b00;
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px;
  cursor: pointer;
  width: 100%;
}
.button:hover
{
color: #5c6847;
}
body {
 background-color: #e8d7c2;
}
h1 {
  text-align: center;
  color: #062b00;
}
p{
color: #062b00;
}
</style>
</head>
<body>
<h1>SZ_WPowerR</h1>
 <div class="center">
<p>Choose action:</p> 
<button class="button" onclick="restart()">Reboot</button>
<button class="button" onclick="power()">Power Off</button>
</div>
<div class="footer">
<p><a href="https://sznetwork.systems">sznetwork.systems</a></p>
</div>
</body>
</html>
    ''')

run(host='0.0.0.0', port=8080)

Link to download source code and compiled file for x86

Download source & compiled
Duino coin compiling and running on Xiaomi Mi TV stick with fasthash
DIY Phone holder from scrap

Leave a Comment

Your email address will not be published. Required fields are marked *