feat: 娣诲姞缃戦〉鐗堝簲鐢ㄥ拰鑳岃鎺掑簭鍔熻兘

- 鍒涘缓Flask缃戦〉搴旂敤妗嗘灦(web_app.py)
- 娣诲姞鑳岃鎺掑簭鍔熻兘锛氱煡璇嗙偣璇嗗埆鍜岄殢鏈烘帓搴?- 瀹炵幇杞洏鎶借儗鍔熻兘(鍩轰簬SVG)
- 鍒涘缓鍓嶇椤甸潰锛氶椤靛拰鑳岃鎺掑簭椤甸潰
- 娣诲姞鍝嶅簲寮廋SS鏍峰紡
- 鍒涘缓鍚姩鑴氭湰(start_web.py)
- 鏇存柊requirements.txt娣诲姞Flask渚濊禆
- 娣诲姞缃戦〉鐗堜娇鐢ㄨ鏄?README_WEB.md)
This commit is contained in:
赵杰 Jie Zhao (雄狮汽车科技)
2025-11-02 20:44:19 +08:00
parent 14521369b9
commit 8b5063a092
9 changed files with 1258 additions and 1 deletions

57
start_web.py Normal file
View File

@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
"""
启动网页应用的脚本
"""
import sys
from pathlib import Path
# 添加项目根目录到Python路径
project_root = Path(__file__).parent
sys.path.insert(0, str(project_root))
def check_flask():
"""检查Flask是否已安装"""
try:
import flask
print(f"✓ Flask已安装 (版本: {flask.__version__})")
return True
except ImportError:
print("✗ Flask未安装请运行: pip install Flask")
return False
def main():
"""启动网页应用"""
print("🌐 启动网页应用...")
print("=" * 50)
if not check_flask():
return False
# 创建必要的目录
Path('templates').mkdir(exist_ok=True)
Path('static/css').mkdir(parents=True, exist_ok=True)
Path('static/js').mkdir(parents=True, exist_ok=True)
Path('logs').mkdir(exist_ok=True)
print("\n🚀 正在启动网页服务器...")
print("=" * 50)
print("📱 访问地址: http://localhost:5000")
print("📝 背诵排序: http://localhost:5000/recitation")
print("\n按 Ctrl+C 停止服务器\n")
try:
from web_app import app
app.run(debug=True, host='0.0.0.0', port=5000)
except KeyboardInterrupt:
print("\n👋 服务器已停止")
except Exception as e:
print(f"\n❌ 启动失败: {e}")
return False
return True
if __name__ == "__main__":
success = main()
if not success:
sys.exit(1)