Skip to content

Commit a0fb94e

Browse files
committed
update
1 parent ee95a9d commit a0fb94e

File tree

2 files changed

+12
-39
lines changed

2 files changed

+12
-39
lines changed

fastapi/app/main.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,18 @@
55
import requests
66
from pydantic import BaseModel
77
from bs4 import BeautifulSoup
8-
8+
from fastapi.middleware.cors import CORSMiddleware
99

1010
app = FastAPI()
1111

12+
app.add_middleware(
13+
CORSMiddleware,
14+
allow_origins=["*"],
15+
allow_credentials=True,
16+
allow_methods=["*"],
17+
allow_headers=["*"],
18+
)
19+
1220
class ArticleResponse(BaseModel):
1321
article: str
1422

ui/src/components/TranslationSection.tsx

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ const TranslationSection = () => {
130130
};
131131
const [availableTranslationLanguages, setAvailableTranslationLanguages] = useState<SelectData<string>[]>([])
132132
const [isLoading, setIsLoading] = useState(false)
133-
const [articleContent, setArticleContent] = useState('');
134133
const form = useForm<TranslationFormType>({
135134
defaultValues: {
136135
sourceArticleUrl: '',
@@ -147,10 +146,9 @@ const TranslationSection = () => {
147146
setValue,
148147
} = form
149148

150-
/*const onSubmit = useCallback(async (data: TranslationFormType) => {
149+
const onSubmit = useCallback(async (data: TranslationFormType) => {
151150
try {
152151
setIsLoading(true)
153-
154152
const response = await fetchArticle({
155153
translationTool,
156154
deepLApiKey: APIKey,
@@ -162,32 +160,13 @@ const TranslationSection = () => {
162160
Object.entries(response.data.articleLanguages).map(([key, value]) => ({
163161
value,
164162
label: key,
165-
})))
166-
163+
})))
167164
} catch (error) {
168165
console.log(error)
169166
} finally {
170167
setIsLoading(false)
171168
}
172-
}, [setValue, translationTool, APIKey])*/
173-
174-
const onSubmit = useCallback(async (data: { sourceArticleUrl: string }) => {
175-
try {
176-
setIsLoading(true)
177-
178-
const mockResponse = {
179-
title: 'Pizza',
180-
content:
181-
'Pizza is a popular Italian dish made of flattened bread dough topped with tomatoes, cheese, and other ingredients, baked in an oven.',
182-
url: 'https://en.wikipedia.org/wiki/Pizza',
183-
}
184-
setArticleContent(mockResponse.content)
185-
} catch (error) {
186-
console.error('Error fetching article:', error)
187-
} finally {
188-
setIsLoading(false)
189-
}
190-
}, [])
169+
}, [setValue, translationTool, APIKey])
191170

192171
const onLanguageChange = useCallback(async (translateArticleUrl: string) => {
193172
try {
@@ -289,20 +268,6 @@ const TranslationSection = () => {
289268
<TableCell>{text.editing}</TableCell>
290269
</TableRow>
291270
))}
292-
{articleContent ? (
293-
<TableRow>
294-
<TableCell className="font-medium">{articleContent}</TableCell>
295-
<TableCell className="font-medium">
296-
Translation functionality is not implemented yet.
297-
</TableCell>
298-
</TableRow>
299-
) : (
300-
<TableRow>
301-
<TableCell className="font-medium">No article content yet.</TableCell>
302-
<TableCell className="font-medium">No translation available.</TableCell>
303-
</TableRow>
304-
)}
305-
306271
</TableBody>
307272
</Table>
308273

0 commit comments

Comments
 (0)