# ============================================================
# [실습] 초간단 GUI 챗봇 (Flask + static 서빙 + REST API)
#
# day1 챗봇을 '웹 입력창'으로. 프론트(static/chatbot.html, chatbot.js)는 제공됨.
# 아래 항목을 직접 구현하세요:
#  1) POST /api/chat : {"message": ...} 받아 gpt-4o-mini 로 답하고 {"answer": ...} 반환
#
# 실행:  python 11_gui_chatbot_실습.py  →  http://localhost:5000
# ============================================================

import os
from flask import Flask, request, jsonify, send_from_directory
from openai import OpenAI
from dotenv import load_dotenv

load_dotenv()
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))

app = Flask(__name__)


@app.route("/")
def index():
    return send_from_directory(app.static_folder, "chatbot.html")


@app.route("/api/chat", methods=["POST"])
def chat():
    message = request.json["message"]
    # 1) 여기에 코드를 작성하세요 (gpt-4o-mini 호출 → jsonify({"answer": ...}) 반환)
    pass


if __name__ == "__main__":
    app.run(debug=True, port=5000)
