Merge branch 'pyside6' of https://git.cckb9998.synology.me/ckh08045/autoTrans into pyside6
This commit is contained in:
commit
762f55deb7
|
|
@ -0,0 +1,74 @@
|
|||
import requests
|
||||
import json
|
||||
|
||||
# FastAPI 서버의 기본 URL (컨테이너 내부 혹은 외부 환경에 맞게 수정)
|
||||
BASE_URL = "http://cckb9998.synology.me:8001"
|
||||
|
||||
def save_image_from_response(response, file_path):
|
||||
"""
|
||||
바이너리 이미지 데이터를 받아서 파일로 저장하는 함수.
|
||||
"""
|
||||
try:
|
||||
# response가 200 OK일 때만 진행
|
||||
if response.status_code == 200:
|
||||
with open(file_path, 'wb') as file:
|
||||
file.write(response.content)
|
||||
print(f"이미지가 {file_path}에 저장되었습니다.")
|
||||
else:
|
||||
print(f"이미지를 처리하지 못했습니다. 상태 코드: {response.status_code}")
|
||||
except Exception as e:
|
||||
print(f"이미지 저장 중 오류 발생: {e}")
|
||||
|
||||
# 단일 이미지 URL을 보내는 테스트
|
||||
def test_single_image_translation():
|
||||
image_url = "https://file.percenty.co.kr/public/652bed8e865b1f32ea62bf1f/products/66f7489b86608659ad011faf/0fbf1050-0a49-4c37-83b5-6279b66d6e48.jpg"
|
||||
data = {
|
||||
"image_url": image_url,
|
||||
"use_celery": False # Celery 비활성화로 직접 처리
|
||||
}
|
||||
|
||||
response = requests.post(f"{BASE_URL}/translate_image/", json=data)
|
||||
if response.status_code == 200:
|
||||
result = response.json()
|
||||
print("Single Image Translation Result:", result)
|
||||
else:
|
||||
print("Failed to process single image translation:", response.status_code)
|
||||
|
||||
# 여러 이미지 URL을 보내는 테스트
|
||||
def test_multiple_images_translation():
|
||||
image_urls = ["https://file.percenty.co.kr/public/652bed8e865b1f32ea62bf1f/products/66f7489b86608659ad011faf/0fbf1050-0a49-4c37-83b5-6279b66d6e48.jpg",
|
||||
"https://file.percenty.co.kr/public/652bed8e865b1f32ea62bf1f/products/66f7489b86608659ad011faf/38c86cad-a183-47f9-b6e3-3c58a0d76232.jpg",
|
||||
"https://file.percenty.co.kr/public/652bed8e865b1f32ea62bf1f/products/66f7489b86608659ad011faf/d20b9712-b9df-404e-bdf6-4cea35f93970.jpg"]
|
||||
|
||||
data = {
|
||||
"image_urls": image_urls,
|
||||
"use_celery": True # Celery 사용으로 비동기 처리
|
||||
}
|
||||
|
||||
response = requests.post(f"{BASE_URL}/translate_images/", json=data)
|
||||
if response.status_code == 200:
|
||||
result = response.json()
|
||||
print("Multiple Images Translation Task IDs:", result)
|
||||
else:
|
||||
print("Failed to process multiple images translation:", response.status_code)
|
||||
|
||||
# Celery 비동기 작업 상태 확인
|
||||
def test_task_status(task_id):
|
||||
response = requests.get(f"{BASE_URL}/task_status/{task_id}")
|
||||
if response.status_code == 200:
|
||||
result = response.json()
|
||||
print(f"Task {task_id} Status:", result)
|
||||
else:
|
||||
print(f"Failed to get status for task {task_id}:", response.status_code)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 단일 이미지 테스트 실행
|
||||
test_single_image_translation()
|
||||
|
||||
# 다중 이미지 테스트 실행
|
||||
test_multiple_images_translation()
|
||||
|
||||
# 예시: 비동기 작업 상태 확인
|
||||
# task_id = "your_task_id_here"
|
||||
# test_task_status(task_id)
|
||||
20
옵션요소.txt
20
옵션요소.txt
|
|
@ -243,4 +243,22 @@ original_data = {
|
|||
"trans_option_5": "DAKC-82",
|
||||
"trans_option_6": "DAKC-130",
|
||||
"trans_option_7": "DAKC-250"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
옵션 선택여부 판별요소
|
||||
|
||||
1번옵션의 삭제편집 div
|
||||
//*[@id="productMainContentContainerId"]/div[1]/div[2]/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div[5]/div[1]/div/div/ul/li[1]/div/div[1]/div/div[2]/div/div[2]
|
||||
1번옵션이 선택해제되었을 경우 생성되는 "제외된 옵션" div
|
||||
//*[@id="productMainContentContainerId"]/div[1]/div[2]/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div[5]/div[1]/div/div/ul/li[1]/div/div[1]/div/div[2]/div/div[3]
|
||||
1번옵션이 선택해제되었을 경우 생성되는 "제외된 옵션" 요소
|
||||
<div class="sc-dfauwV bXsMpn"><span class="sc-bKNmIE fZvctk">제외된 옵션</span></div>
|
||||
|
||||
2번옵션의 삭제편집 div
|
||||
//*[@id="productMainContentContainerId"]/div[1]/div[2]/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div[5]/div[1]/div/div/ul/li[2]/div/div[1]/div/div[2]/div/div[2]
|
||||
2번옵션이 선택해제되었을 경우 생성되는 "제외된 옵션" div
|
||||
//*[@id="productMainContentContainerId"]/div[1]/div[2]/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div[5]/div[1]/div/div/ul/li[2]/div/div[1]/div/div[2]/div/div[3]
|
||||
2번옵션이 선택해제되었을 경우 생성되는 "제외된 옵션" 요소
|
||||
<div class="sc-dfauwV bXsMpn"><span class="sc-bKNmIE fZvctk">제외된 옵션</span></div>
|
||||
Loading…
Reference in New Issue