Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. import falcon
  2. from wsgiref import simple_server
  3. import socket
  4.  
  5. host = '10.88.111.49'
  6. port = 9100
  7. cut = chr(27) + '@' + chr(29) + 'V' + chr(1)
  8.  
  9. class PrintResource(object):
  10. def on_post(self, req, resp):
  11. resp.status = falcon.HTTP_200
  12. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  13. s.connect((host, port))
  14. print req.get_param("body", required=True)
  15. s.sendall(bytearray(req.get_param("body", required=True) + cut.encode('ascii')))
  16. s.close()
  17.  
  18. if __name__ == '__main__':
  19. app = falcon.API()
  20.  
  21. print_resource = PrintResource()
  22.  
  23. app.add_route('/print', print_resource)
  24. app.req_options.auto_parse_form_urlencoded = True
  25.  
  26. httpd = simple_server.make_server('127.0.0.1', 8000, app)
  27. print "u wanna fuc??"
  28. httpd.serve_forever()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement