from fastapi import FastAPI, Query from typing import List import WebScout_Deep_DDC app = FastAPI() @app.get('/search') async def search( query: str = Query(..., description="The search query"), result_num: int = Query(10, description="Number of results to retrieve"), safe: bool = Query(True, description="Enable safe search"), extract_webpage: bool = Query(True, description="Extract webpage content"), overwrite_query_html: bool = Query(False, description="Overwrite query HTML"), overwrite_webpage_html: bool = Query(False, description="Overwrite webpage HTML") ): 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 JSON return response 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 error_message, 400 # Example Usage : http://127.0.0.1:8000/search?query=python&safe=true