Spaces:
Runtime error
Runtime error
from flask import Flask, request, jsonify | |
import WebScout_DDC | |
app = Flask(__name__) | |
def search(): | |
# Extract query parameter | |
query = request.args.get('query') | |
# Extract additional parameters | |
max_results = int(request.args.get('max_results', 10)) | |
if query: | |
# Call the main function with the specified parameters | |
titles_list, urls_list, text_list = WebScout_DDC.main( | |
query, | |
max_results=max_results, | |
) | |
# Create a dictionary containing the extracted attributes | |
response = { | |
'titles': titles_list, | |
'urls': urls_list, | |
'text': text_list | |
} | |
# Return the response as prettified JSON | |
return jsonify(response), 200, {'Content-Type': 'application/json; charset=utf-8'} | |
else: | |
error_message = { | |
'developer_contact': { | |
'telegram': 'https://t.me/DevsDoCode', | |
'instagram': 'https://www.instagram.com/sree.shades_/', | |
'discord': 'https://discord.gg/ehwfVtsAts', | |
'linkedin': 'https://www.linkedin.com/in/developer-sreejan/', | |
'twitter': 'https://twitter.com/Anand_Sreejan' | |
}, | |
'error': 'Oops! Something went wrong. Please contact the developer for assistance.' | |
} | |
return jsonify(error_message), 400 | |
if __name__ == '__main__': | |
app.run(debug=True) | |
# Example Usage : http://127.0.0.1:5000/search?query=python%20tutorial&result_num=20&safe=False&types=web&types=video&extract_webpage=False |