Skip to content

Commit c158cbb

Browse files
authored
Update and rename app.py to function_app.py
1 parent 6835eb4 commit c158cbb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

app.py function_app.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
import logging
12
from flask import Flask, request, jsonify
23
import joblib
34
import numpy as np
5+
import azure.functions as func
46

7+
# Flask 앱 생성
58
app = Flask(__name__)
69

10+
# 모델 및 스케일러 로드
711
model = joblib.load("stress_model.pkl")
812
scaler = joblib.load("scaler.pkl")
913

@@ -42,5 +46,7 @@ def predict_stress_endpoint():
4246
except Exception as e:
4347
return jsonify({"error": str(e)}), 500
4448

45-
if __name__ == '__main__':
46-
app.run(debug=True)
49+
# Azure Functions용 엔트리 포인트
50+
def main(req: func.HttpRequest, context: func.Context) -> func.HttpResponse:
51+
from azure.functions._http_wsgi import WsgiMiddleware
52+
return WsgiMiddleware(app).handle(req, context)

0 commit comments

Comments
 (0)