Actualizar badger.py
This commit is contained in:
parent
19dd19a4ba
commit
3eb8d5b456
32
badger.py
32
badger.py
@ -175,7 +175,6 @@ HTML_TEMPLATE = """
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
"""
|
||||
|
||||
@app.route("/", methods=["GET", "POST"])
|
||||
@ -195,14 +194,33 @@ def index():
|
||||
filters["has_description"] = "has_description" in request.form
|
||||
filters["has_hostname"] = "has_hostname" in request.form
|
||||
|
||||
# Filter based on the search query
|
||||
if search_query:
|
||||
# Split the query by space to handle the negative term search
|
||||
positive_terms = []
|
||||
negative_terms = []
|
||||
for term in search_query.split():
|
||||
if term.startswith('-'):
|
||||
negative_terms.append(term[1:]) # Remove the "-" for negative terms
|
||||
else:
|
||||
positive_terms.append(term)
|
||||
|
||||
# Filter based on the positive terms
|
||||
if positive_terms:
|
||||
results = [
|
||||
entry for entry in results
|
||||
if search_query in entry["ip"].lower()
|
||||
or search_query in entry["title"].lower()
|
||||
or search_query in entry["description"].lower()
|
||||
or search_query in entry["hostname"].lower()
|
||||
if any(term in entry["ip"].lower() for term in positive_terms) or
|
||||
any(term in entry["title"].lower() for term in positive_terms) or
|
||||
any(term in entry["description"].lower() for term in positive_terms) or
|
||||
any(term in entry["hostname"].lower() for term in positive_terms)
|
||||
]
|
||||
|
||||
# Exclude based on the negative terms
|
||||
if negative_terms:
|
||||
results = [
|
||||
entry for entry in results
|
||||
if not any(term in entry["ip"].lower() for term in negative_terms) and
|
||||
not any(term in entry["title"].lower() for term in negative_terms) and
|
||||
not any(term in entry["description"].lower() for term in negative_terms) and
|
||||
not any(term in entry["hostname"].lower() for term in negative_terms)
|
||||
]
|
||||
|
||||
# Apply the checkbox filters
|
||||
|
Loading…
Reference in New Issue
Block a user