Spaces:
Runtime error
Runtime error
File size: 1,866 Bytes
12fdc0e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
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 |