from flask import Flask, request, jsonify import WebScout_Deep_DDC app = Flask(__name__) @app.route('/search', methods=['GET']) def search(): # Extract query parameter query = request.args.get('query') # Extract additional parameters result_num = int(request.args.get('result_num', 10)) safe = request.args.get('safe', True) extract_webpage = request.args.get('extract_webpage', True) overwrite_query_html = request.args.get('overwrite_query_html', False) overwrite_webpage_html = request.args.get('overwrite_webpage_html', False) if query: # Call the main function with the specified parameters titles_list, urls_list, text_list = WebScout_Deep_DDC.main( query, result_num=result_num, safe=safe, extract_webpage=extract_webpage, overwrite_query_html=overwrite_query_html, overwrite_webpage_html=overwrite_webpage_html ) # 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