Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import cherrypy
- WEBHOOK_PORT = 8443 # 443, 80, 88 или 8443
- WEBHOOK_LISTEN = '0.0.0.0' # Слушаем отовсюду
- #WEBHOOK_SSL_CERT = 'webhook_cert.pem' # Путь к сертификату
- #WEBHOOK_SSL_PRIV = 'webhook_pkey.pem' # Путь к закрытому ключу
- class WebServer(object):
- @cherrypy.expose
- def winbox(self,ip,login,pswd):
- ip = ip.strip()
- login = login.strip()
- pswd = pswd.strip()
- if not ip:
- return "Please give an ip address... ;-)"
- data = ["c:/dev/winbox/winbox.exe", ip, login, pswd]
- subprocess.Popen(data, shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, creationflags = 0x00000008)
- return 'Starting winbox to ' + ip
- @cherrypy.expose
- def ssh(self,ip,login,pswd):
- ip = ip.strip()
- login = login.strip()
- pswd = pswd.strip()
- if not ip:
- return "Please give an ip address... ;-)"
- cmd = "c:/dev/putty/putty.exe -ssh "
- if login:
- cmd = cmd + login + "@"
- cmd = cmd + ip
- if pswd:
- cmd = cmd + " -pw " + pswd
- subprocess.Popen(cmd, shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, creationflags = 0x00000008)
- return "Starting ssh to " + ip
- @cherrypy.expose
- def index(self):
- return "Hello world"
- if __name__ == '__main__':
- cherrypy.config.update({
- 'server.socket_host': WEBHOOK_LISTEN,
- 'server.socket_port': WEBHOOK_PORT,
- 'server.ssl_module': 'builtin',
- #'server.ssl_certificate': WEBHOOK_SSL_CERT,
- #'server.ssl_private_key': WEBHOOK_SSL_PRIV,
- 'engine.autoreload.on': False
- })
- cherrypy.quickstart(WebServer(), '/', {'/': {}})
Advertisement
Add Comment
Please, Sign In to add comment