可运行
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from flask import Flask
|
||||
from flask_script import Manager
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
|
||||
|
||||
import os
|
||||
|
||||
# 先创建db实例
|
||||
db = SQLAlchemy()
|
||||
|
||||
class Application( Flask ):
|
||||
def __init__(self,import_name,template_folder=None,root_path = None):
|
||||
super( Application,self ).__init__( import_name ,template_folder=template_folder,root_path = root_path,static_folder = None)
|
||||
@@ -12,14 +15,14 @@ class Application( Flask ):
|
||||
if "ops_config" in os.environ:
|
||||
self.config.from_pyfile( 'config/%s_setting.py'%os.environ['ops_config'] )
|
||||
# 设置数据库连接 URI
|
||||
self.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:123456@127.0.0.1/food_db?charset=utf8mb4'
|
||||
self.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:!Rjb12191@gz-cynosdbmysql-grp-d26pzce5.sql.tencentcdb.com:24936/food_db?charset=utf8mb4'
|
||||
# 禁用对象修改跟踪
|
||||
self.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
||||
# 初始化数据库
|
||||
db.init_app( self )
|
||||
|
||||
db = SQLAlchemy()
|
||||
# 创建应用实例
|
||||
app = Application( __name__,template_folder=os.getcwd()+"/web/templates/" ,root_path = os.getcwd())
|
||||
manager = Manager( app )
|
||||
|
||||
'''
|
||||
函数模板
|
||||
|
||||
Reference in New Issue
Block a user