-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
37 lines (31 loc) ยท 1022 Bytes
/
app.py
File metadata and controls
37 lines (31 loc) ยท 1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from flask import Flask, request
from flask_cors import CORS
from api.routes import chatbot_bp # routes.py์ ๋ธ๋ฃจํ๋ฆฐํธ ์ํฌํธ
import logging
import os
# logs ๋๋ ํ ๋ฆฌ ์์ผ๋ฉด ์์ฑ
if not os.path.exists('logs'):
os.makedirs('logs')
# ๋ก๊ทธ ์ค์
logging.basicConfig(
filename='logs/flask.log',
level=logging.INFO,
format='%(asctime)s [%(levelname)s] %(message)s',
)
logger = logging.getLogger(__name__)
app = Flask(__name__)
CORS(
app,
origins=["https://kikibot.netlify.app", "https://howkiki.netlify.app", "http://localhost:3000"],
methods=["GET", "POST", "OPTIONS"],
allow_headers=["Content-Type", "Authorization"]
)
# ๋ชจ๋ ์์ฒญ์ ๋ก๊ทธ๋ก ์ถ๋ ฅ
@app.before_request
def log_request():
logger.info(f"{request.method} ์์ฒญ ๋์ฐฉ: {request.path}")
# ๋ธ๋ฃจํ๋ฆฐํธ ๋ฑ๋ก (์: /api/chat์ผ๋ก ์ ๊ทผ)
app.register_blueprint(chatbot_bp, url_prefix='/api')
# ์๋ฒ ์คํ
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=5000)