Added python.html
This commit is contained in:
parent
d32d9a5d8c
commit
5fc65e393f
58
python.html
Normal file
58
python.html
Normal file
@ -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>
|
Loading…
x
Reference in New Issue
Block a user