Spaces:
Sleeping
Sleeping
Update api.py
Browse files
api.py
CHANGED
@@ -6,7 +6,7 @@ import tensorflow as tf
|
|
6 |
from scraper import scrape_text
|
7 |
from fastapi import FastAPI, Response, Request
|
8 |
from typing import List
|
9 |
-
from pydantic import BaseModel, Field,
|
10 |
import uvicorn
|
11 |
import json
|
12 |
import logging
|
@@ -135,8 +135,8 @@ def authenticate_key(api_key: str):
|
|
135 |
raise NewsSummarizerAPIAuthenticationError("Authentication error: Invalid API key.")
|
136 |
|
137 |
|
138 |
-
@app.exception_handler(
|
139 |
-
async def validation_exception_handler(request: Request, exc:
|
140 |
urls = request.query_params.getlist("urls")
|
141 |
error_details = exc.errors()
|
142 |
error_messages = []
|
|
|
6 |
from scraper import scrape_text
|
7 |
from fastapi import FastAPI, Response, Request
|
8 |
from typing import List
|
9 |
+
from pydantic import BaseModel, Field, RequestValidationError
|
10 |
import uvicorn
|
11 |
import json
|
12 |
import logging
|
|
|
135 |
raise NewsSummarizerAPIAuthenticationError("Authentication error: Invalid API key.")
|
136 |
|
137 |
|
138 |
+
@app.exception_handler(RequestValidationError)
|
139 |
+
async def validation_exception_handler(request: Request, exc: RequestValidationError):
|
140 |
urls = request.query_params.getlist("urls")
|
141 |
error_details = exc.errors()
|
142 |
error_messages = []
|