Пример #1
0
def create_app():
  app = Flask(__name__)

  from flask_bootstrap import Bootstrap
  Bootstrap(app)

  app.config['WTF_CSRF_SECRET_KEY'] = 'mysecretkey1234567890'
  app.config['SECRET_KEY'] = 'mysecretkey1234567890'
  app.config['DEBUG'] = True
  app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///" + db_path
  app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

  db.init_app(app)

  from flask_sqlite_web.core import sqliteAdminBlueprint
  sqliteAdminBP = sqliteAdminBlueprint(title='Exaqmple',h1='Example',dbPath = db_path)
  app.register_blueprint(sqliteAdminBP, url_prefix='/sqlite')

  return app
Пример #2
0
def create_app():
  app = Flask(__name__)

  from flask_bootstrap import Bootstrap
  Bootstrap(app)

  app.config['WTF_CSRF_SECRET_KEY'] = 'mysecretkey1234567890'
  app.config['SECRET_KEY'] = 'mysecretkey1234567890'
  app.config['DEBUG'] = False
  app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///" + db_path
  app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

  db.init_app(app)

  from flask_sqlite_web.core import sqliteAdminBlueprint
  sqliteAdminBP = sqliteAdminBlueprint(title=u'成绩查询',h1=u'2018中国大学生射箭(射艺)锦标赛-实时成绩查询',dbPath = db_path)
  app.register_blueprint(sqliteAdminBP, url_prefix='/ucac/score')
  app.debug = False
  return app
Пример #3
0
def register_db(app):
    # 注册数据库
    db.init_app(app)
    cache.init_app(app)
Пример #4
0
import configparser

from resources.person import Statistics, PersonConcept
from resources.concept import Concept
from resources.visit_occurrence import VisitOccurrenceConcept
from resources.condition_occurrence import ConditionOccurrenceConcept
from resources.drug_exposure import DrugExposureConcept

config = configparser.ConfigParser()
config.read('config.ini')
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = config['DATABASE'][
    'SQLALCHEMY_DATABASE_URI']
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

api = Api(app)
swagger = Swagger(app, parse=True)

api.add_resource(Statistics, '/statistics')
api.add_resource(Concept, '/concept/<concept_name>')
api.add_resource(PersonConcept, '/person/<type>/<value>')
api.add_resource(VisitOccurrenceConcept, '/visit_occurrence/<type>/<value>')
api.add_resource(ConditionOccurrenceConcept,
                 '/condition_occurrence/<type>/<value>')
api.add_resource(DrugExposureConcept, '/drug_exposure/<type>/<value>')

if __name__ == "__main__":
    from db_init import db
    db.init_app(app)
    app.run()