chore: Add function to clear the database
This commit is contained in:
8
main.py
8
main.py
@@ -10,7 +10,7 @@ import asyncio
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
import chromedriver_autoinstaller
|
||||
from functools import lru_cache
|
||||
from crawler.database import get_total_count
|
||||
from crawler.database import get_total_count, clear_db
|
||||
import os
|
||||
import uuid
|
||||
|
||||
@@ -56,6 +56,12 @@ async def get_total_url_count():
|
||||
count = get_total_count(db_path='crawler_data.db')
|
||||
return JSONResponse(content={"count": count})
|
||||
|
||||
# Add endpoit to clear db
|
||||
@app.get("/clear-db")
|
||||
async def clear_database():
|
||||
clear_db(db_path='crawler_data.db')
|
||||
return JSONResponse(content={"message": "Database cleared."})
|
||||
|
||||
@app.post("/crawl")
|
||||
async def crawl_urls(urls_input: UrlsInput, request: Request):
|
||||
global current_requests
|
||||
|
||||
Reference in New Issue
Block a user