Created
May 13, 2023 17:29
-
-
Save duhow/083e6c9f19fac3b6e646b8d1375a7c0d to your computer and use it in GitHub Desktop.
Forward scans from Binary Eye to input system (Remote Barcode Scanner)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: ChatGPT-3.5 | |
# SPDX-License-Identifier: WTFPL | |
# See: https://github.com/markusfisch/BinaryEye | |
# Description: Binary Eye forward scans to input content to system | |
# pip install autopygui | |
from http.server import BaseHTTPRequestHandler, HTTPServer | |
from urllib.parse import urlparse, parse_qs | |
import pyautogui | |
import sys | |
# Define the handler for the HTTP requests | |
class RequestHandler(BaseHTTPRequestHandler): | |
# Handle GET requests | |
def do_GET(self): | |
# Parse the URL and extract the query parameters | |
parsed_url = urlparse(self.path) | |
query_params = parse_qs(parsed_url.query) | |
# Check if 'content' parameter exists | |
if 'content' in query_params: | |
# Get the value of 'content' | |
content = query_params['content'][0] | |
# Simulate keyboard strokes to write the content to an Excel spreadsheet | |
pyautogui.typewrite(content) | |
pyautogui.press('enter') | |
# Send a response to the client | |
self.send_response(200) | |
self.send_header('Content-type', 'text/plain') | |
self.end_headers() | |
self.wfile.write(b'Input sent to the system') | |
else: | |
# Invalid request, missing 'content' parameter | |
self.send_response(400) | |
self.send_header('Content-type', 'text/plain') | |
self.end_headers() | |
self.wfile.write(b'Missing query parameter: content') | |
return | |
# Run the web server | |
def run_server(): | |
# Specify the host and port number | |
host = '0.0.0.0' | |
port = 8001 | |
# Create the HTTP server | |
server = HTTPServer((host, port), RequestHandler) | |
print(f'Starting server on {host}:{port}...') | |
try: | |
# Keep the server running until interrupted | |
server.serve_forever() | |
except KeyboardInterrupt: | |
pass | |
# Close the server | |
server.server_close() | |
print('Server stopped.') | |
if __name__ == '__main__': | |
run_server() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment