44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
神东煤炭综采工作面数据管理与AI分析系统
|
|
主入口文件
|
|
"""
|
|
import logging
|
|
from flask import Flask, send_from_directory
|
|
from flask_cors import CORS
|
|
from config import Config
|
|
from routes import api
|
|
from tag_names import init_for_app
|
|
|
|
# 配置日志
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format='%(asctime)s [%(levelname)s] %(name)s: %(message)s'
|
|
)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
def create_app(config_class=Config):
|
|
app = Flask(__name__, static_folder='static', static_url_path='/static')
|
|
app.config.from_object(config_class)
|
|
|
|
# 启用CORS
|
|
CORS(app, resources={r"/api/*": {"origins": "*"}})
|
|
|
|
# 注册API蓝图
|
|
app.register_blueprint(api)
|
|
|
|
# 预加载标签名称映射
|
|
with app.app_context():
|
|
init_for_app(app)
|
|
|
|
# 静态页面路由
|
|
@app.route('/')
|
|
def index():
|
|
return send_from_directory('static', 'index.html')
|
|
|
|
return app
|
|
|
|
if __name__ == '__main__':
|
|
app = create_app()
|
|
app.run(host='0.0.0.0', port=5000, debug=True) |