fraud-detection-ml/App/__init__.py
2025-02-26 22:25:44 +08:00

27 lines
940 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# __init__.py 初始化文件创建Flask应用
import pymysql
from .exts import init_exts
from flask import Flask
from . import *
from .views import blus
def create_app():
app = Flask(__name__)
# 注册蓝图
app.register_blueprint(blueprint=blus)
# MySQL所在主机名默认127.0.0.1
HOSTNAME = "192.168.15.2"
# MySQL监听的端口号默认3306
PORT = 3306
# 连接MySQL的用户名自己设置
USERNAME = "root"
# 连接MySQL的密码自己设置
PASSWORD = "minxianrui"
# MySQL上创建的数据库名称
DATABASE = "fraud_detection_ml"
# 通过修改以下代码来操作不同的SQL比写原生SQL简单很多 --》通过ORM可以实现从底层更改使用的SQL
app.config[
'SQLALCHEMY_DATABASE_URI'] = f"mysql+pymysql://{USERNAME}:{PASSWORD}@{HOSTNAME}:{PORT}/{DATABASE}?charset=utf8mb4"
# 初始化插件
init_exts(app=app)
return app