-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0a5b42
commit 31a97d6
Showing
12 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
FLASK_APP=base.py | ||
FLASK_ENV=development |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
from flask import Flask, jsonify, request | ||
import google.generativeai as genai | ||
import requests | ||
from flask_cors import CORS | ||
|
||
app = Flask(__name__) | ||
CORS(app) | ||
|
||
API_KEY = URLSCAN_API_KEY | ||
genai.configure(api_key=LLM_API_KEY) | ||
|
||
|
||
@app.route('/api/domain-search', methods=['GET']) | ||
def domain_search(): | ||
domain = request.args.get('domain') | ||
if not domain: | ||
return jsonify({"error": "No domain provided"}), 400 | ||
|
||
urlscan_url = f'https://urlscan.io/api/v1/search/?q=domain:{domain}' | ||
headers = { | ||
'API-Key': API_KEY, | ||
'Content-Type': 'application/json' | ||
} | ||
|
||
try: | ||
response = requests.get(urlscan_url, headers=headers) | ||
response.raise_for_status() | ||
return jsonify(response.json()) | ||
except requests.exceptions.HTTPError as err: | ||
return jsonify({"error": f"HTTP Error: {str(err)}"}), response.status_code | ||
except requests.exceptions.RequestException as e: | ||
return jsonify({"error": "A network error occurred", "details": str(e)}), 500 | ||
|
||
@app.route('/api/advance-domain-search', methods=['GET']) | ||
def advance_domain_search(): | ||
domain = request.args.get('resultURL') | ||
if not domain: | ||
return jsonify({"error": "No domain provided"}), 400 | ||
|
||
headers = { | ||
'API-Key': API_KEY, | ||
'Content-Type': 'application/json' | ||
} | ||
|
||
try: | ||
response = requests.get(domain, headers=headers) | ||
response.raise_for_status() | ||
return jsonify(response.json()) | ||
except requests.exceptions.HTTPError as err: | ||
return jsonify({"error": f"HTTP Error: {str(err)}"}), response.status_code | ||
except requests.exceptions.RequestException as e: | ||
return jsonify({"error": "A network error occurred", "details": str(e)}), 500 | ||
|
||
|
||
@app.route('/api/takedown', methods=['GET']) | ||
def takedown(): | ||
infringing_content = request.args.get('infringingContent') | ||
brand_content = request.args.get('brandContent') | ||
selected_reason = request.args.get('selectedReason') | ||
detailed_description = request.args.get('detailedDescription') | ||
|
||
print(f"Infringing Content: {infringing_content}") | ||
print(f"Brand Content: {brand_content}") | ||
print(f"Selected Reason: {selected_reason}") | ||
print(f"Detailed Description: {detailed_description}") | ||
|
||
model = genai.GenerativeModel('gemini-1.5-flash') | ||
response = model.generate_content(f""" | ||
Task: | ||
1. Review the following details provided: | ||
- Infringing Content: {infringing_content} | ||
- Brand Content: {brand_content} | ||
- Reason for Infringement: {selected_reason} | ||
- Detailed Description: {detailed_description} | ||
2. Generate a formal Takedown Notice using the provided information. | ||
Your response must be in the following format and should not include any other information. If insufficient information is provided, then generate a generalised response. ONLY GENERATE A NOTICE, NO CROSS QUESTIONING: | ||
- Takedown Notice: | ||
[notice_body] | ||
Your response: | ||
""") | ||
|
||
print(response.text) | ||
|
||
response_data = { | ||
"notice": response.text | ||
} | ||
|
||
return jsonify(response_data) | ||
|
||
if __name__ == '__main__': | ||
app.run(debug=True) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
annotated-types==0.7.0 | ||
blinker==1.8.2 | ||
cachetools==5.4.0 | ||
certifi==2024.7.4 | ||
charset-normalizer==3.3.2 | ||
click==8.1.7 | ||
Flask==3.0.3 | ||
Flask-Cors==4.0.1 | ||
google-ai-generativelanguage==0.6.6 | ||
google-api-core==2.19.1 | ||
google-api-python-client==2.141.0 | ||
google-auth==2.33.0 | ||
google-auth-httplib2==0.2.0 | ||
google-generativeai==0.7.2 | ||
googleapis-common-protos==1.63.2 | ||
grpcio==1.65.5 | ||
grpcio-status==1.62.3 | ||
httplib2==0.22.0 | ||
idna==3.7 | ||
itsdangerous==2.2.0 | ||
Jinja2==3.1.4 | ||
MarkupSafe==2.1.5 | ||
proto-plus==1.24.0 | ||
protobuf==4.25.4 | ||
pyasn1==0.6.0 | ||
pyasn1_modules==0.4.0 | ||
pydantic==2.8.2 | ||
pydantic_core==2.20.1 | ||
pyparsing==3.1.2 | ||
python-dotenv==1.0.1 | ||
requests==2.32.3 | ||
rsa==4.9 | ||
tqdm==4.66.5 | ||
typing_extensions==4.12.2 | ||
uritemplate==4.1.1 | ||
urllib3==2.2.2 | ||
Werkzeug==3.0.3 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.