mirror of
https://github.com/won-ktds/smarketing-backend.git
synced 2025-12-06 07:06:24 +00:00
refacotr: temp 폴더 삭제
This commit is contained in:
parent
21e7ddeb92
commit
1f8d6c2f4b
@ -22,11 +22,6 @@ def create_app():
|
||||
# CORS 설정
|
||||
CORS(app)
|
||||
|
||||
# 업로드 폴더 생성
|
||||
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
|
||||
os.makedirs(os.path.join(app.config['UPLOAD_FOLDER'], 'temp'), exist_ok=True)
|
||||
os.makedirs('templates/poster_templates', exist_ok=True)
|
||||
|
||||
# 서비스 인스턴스 생성
|
||||
poster_service = PosterService()
|
||||
sns_content_service = SnsContentService()
|
||||
|
||||
@ -1,42 +1,53 @@
|
||||
"""
|
||||
마케팅 팁 API 테스트 스크립트
|
||||
"""
|
||||
# openai_simple_test.py
|
||||
import requests
|
||||
import json
|
||||
|
||||
|
||||
def test_marketing_tip_api():
|
||||
"""마케팅 팁 API 테스트"""
|
||||
|
||||
# 테스트 데이터
|
||||
test_data = {
|
||||
"store_name": "더블샷 카페",
|
||||
"business_type": "카페",
|
||||
"location": "서울시 강남구 역삼동",
|
||||
"seat_count": 30,
|
||||
}
|
||||
|
||||
# API 호출
|
||||
url = "http://localhost:5001/api/v1/generate-marketing-tip"
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer dummy-key"
|
||||
}
|
||||
import os
|
||||
from utils.ai_client import AIClient
|
||||
import openai
|
||||
import base64
|
||||
|
||||
def openai_test(prompt: str,):
|
||||
try:
|
||||
response = requests.post(url, json=test_data, headers=headers)
|
||||
|
||||
print(f"Status Code: {response.status_code}")
|
||||
print(f"Response: {json.dumps(response.json(), ensure_ascii=False, indent=2)}")
|
||||
|
||||
if response.status_code == 200:
|
||||
print("✅ 테스트 성공!")
|
||||
openai_api_key = os.getenv('OPENAI_API_KEY')
|
||||
if openai_api_key:
|
||||
openai_client = openai.OpenAI(api_key=openai_api_key)
|
||||
else:
|
||||
print("❌ 테스트 실패!")
|
||||
openai_client = None
|
||||
|
||||
if not openai_client:
|
||||
raise Exception("OpenAI API 키가 설정되지 않았습니다.")
|
||||
|
||||
response = openai_client.images.generate(
|
||||
model="dall-e-3",
|
||||
prompt=prompt,
|
||||
size="1024x1024",
|
||||
n=1,
|
||||
)
|
||||
|
||||
|
||||
# # Azure Blob Storage에 업로드
|
||||
# blob_url = self.blob_client.upload_image(image_data, 'png')
|
||||
|
||||
print(f"✅ 이미지 생성 및 업로드 완료: {response}")
|
||||
return response
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ 테스트 오류: {str(e)}")
|
||||
|
||||
raise Exception(f"이미지 생성 실패: {str(e)}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_marketing_tip_api()
|
||||
# API 키 확인
|
||||
if not os.getenv('OPENAI_API_KEY'):
|
||||
print("⚠️ 환경변수 OPENAI_API_KEY가 설정되지 않았습니다.")
|
||||
print("코드 상단의 'your-api-key-here' 부분에 실제 API 키를 입력하거나")
|
||||
print("export OPENAI_API_KEY='실제키' 로 환경변수를 설정해주세요.\n")
|
||||
|
||||
openai_test("""아래 정보를 활용하여 사람 그림을 그려주세요.
|
||||
- 성별 : 여자
|
||||
- 나이 : 27살
|
||||
- 머리 : 머리 긴 편, 아래쪽에 웨이브, 앞머리 약간 있음
|
||||
- 동양인
|
||||
- 쌍커풀 없음
|
||||
- 밝은 이미지
|
||||
- 웃는 모습
|
||||
현실적인 모습으로 그려주세요.
|
||||
사진에 글자가 절대 들어가지 않게 해주세요.
|
||||
""")
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 190 KiB |
Loading…
x
Reference in New Issue
Block a user