From 5fc65e393f78d0e7ea6844222cf13cf4969109a5 Mon Sep 17 00:00:00 2001 From: anon <anon@anon.anon> Date: Sun, 10 Mar 2024 15:57:36 +0100 Subject: [PATCH] Added python.html --- python.html | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 python.html diff --git a/python.html b/python.html new file mode 100644 index 0000000..644f3c8 --- /dev/null +++ b/python.html @@ -0,0 +1,58 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <!-- Your existing head content --> + + <!-- Brython CDN --> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/brython/3.10.0/brython.js"></script> +</head> +<body> + +<div class="container"> + <div class="row"> + <div class="col-md-6 offset-md-3"> + <!-- Search Bar --> + <input type="text" class="form-control" id="searchInput" placeholder="Type something and press Enter"> + + <!-- Results Box --> + <div id="results-box" class="mt-3"></div> + </div> + </div> +</div> + +<!-- Your existing Bootstrap JS and Popper.js --> + +<!-- Custom JavaScript for handling the search --> +<script type="text/python"> +from browser import document + +def handle_search(): + search_input = document['searchInput'].value.strip() + + if search_input: + # Process the search term (replace this with your own logic) + result = process_search(search_input) + + # Append result to the results box + results_box = document['results-box'] + results_box.html += f'<p class="alert alert-success">{result}</p>' + + # Clear the search input + document['searchInput'].value = '' + +def process_search(search_term): + # Your Python function logic here + # For now, just returning the search term as an example + return f"Result: {search_term}" + +# Attach the handle_search function to the Enter key event +document['searchInput'].bind('keyup', lambda ev: handle_search() if ev.key == 'Enter' else None) +</script> + +<!-- Execute Brython script --> +<script type="text/javascript"> + brython({debug:1, indexedDB:1}); +</script> + +</body> +</html>