Advertisement
d3fault33

Hug_python

Jun 18th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. import hug
  2. import subprocess
  3.  
  4. @hug.get('/status')
  5. @hug.cli()
  6. def root():
  7.     out= subprocess.getoutput("/etc/init.d/apache2 status")
  8.     return out
  9.  
  10. @hug.get('/apache_start')
  11. @hug.cli()
  12. def root():
  13.     out= subprocess.getoutput("/etc/init.d/apache2 start")
  14.     return out
  15.  
  16. @hug.get('/apache_stop')
  17. @hug.cli()
  18. def root():
  19.     out= subprocess.getoutput("/etc/init.d/apache2 stop")
  20.     return out
  21.  
  22.  
  23. if __name__ == '__main__':
  24.     add.interface.cli()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement