tcm_expert_builder / test_app.py
leonsimon23's picture
Create test_app.py
2bc224f verified
raw
history blame contribute delete
939 Bytes
from flask import Flask, jsonify
import os
import sys
# 创建一个非常简单的Flask应用实例
app = Flask(__name__)
# 获取当前Python版本,用于诊断
python_version = sys.version
@app.route('/')
def home():
"""一个简单的主页路由,返回HTML"""
# 打印日志,确认请求已到达
print(">>> [Test App] Home route '/' was accessed.")
return "<h1>Hello, TCM Expert Builder!</h1><p>The basic Flask app is running correctly.</p>"
@app.route('/health')
def health_check():
"""一个健康检查API端点,返回JSON"""
print(">>> [Test App] Health check '/health' was accessed.")
return jsonify({
"status": "ok",
"message": "The Gunicorn server is up and responding.",
"python_version": python_version,
"app_cwd": os.getcwd() # 打印当前工作目录
})
# 这个文件不需要 if __name__ == '__main__':, 因为gunicorn会直接导入app实例