Exemplo n.º 1
0
def test_client():
    app = create_app()

    with app.app_context() as ctx:
        ctx.push()

        init_database()

        yield app.test_client()

        db.session.remove()
        db.drop_all()

        ctx.pop()
Exemplo n.º 2
0
# @Time     :2020/4/30 0030 22:38
# @Author   :Eric
# @Email    :[email protected]
# @File     :package_init.py
# @Software :PyCharm
'''
__init__.py 文件
当导入包的时候,默认调用包中的__init__.py文件
作用:
1.当导入包的时候,把一些初始化的函数,变量,类定义在__init__.py文件中
2.此文件中函数,变量等的访问,只需要通过包名.函数...
3.结合__all__=[通过*可以访问的模块]
'''
# 直接导入包user
import user  # user的__init__文件
# 从包user中导入models模块的User类
from user.models import User  # user的__init__文件
user.create_app()
user.printA()

# from 模块 import *   # 表示可以使用模块里面的所有内容,如果没有加__all__=['', ''],
# 但是如果加上__all__, 只有__all__ = [’‘, ’‘]列表中的可以访问
# from 包   import *   # 表示该包中的内容(模块)是不能完全访问的,就需要在__init__.py文件中
# 定义__all__=[可以通过*访问的模块]

from user import *

user1 = models.User('admin', '123456')
user1.show()

print(tst.MAX)
Exemplo n.º 3
0
-------
    * Name: 
        - Guya E-commerce & Guya Express
    * Sub Project Name:
        - User Service
    * Description
        - User Catalog Service
"""


"""Package details

Application features:
--------------------
    Python 3.7
    Flask
    PEP-8 for code style


This module contains the factory function 'create_app' that is
responsible for initializing the application according
to a previous configuration.
"""

import os
from waitress import serve

import user

serve(user.create_app(), host = os.getenv('HOST'), port = int(os.getenv('PORT')))
Exemplo n.º 4
0
from cred import Cred

from flask import Flask, render_template, request, url_for, abort, flash, redirect, current_app
from flaskext.mysql import MySQL
from flask_login import current_user
from flask_user import login_required

from json import dumps
from string import ascii_lowercase, ascii_uppercase

import user

app = user.create_app()
app.secret_key = 'i_really_love_cookies'
mysql = MySQL()

app.config['MYSQL_DATABASE_USER'] = Cred['MYSQL_DATABASE_USER']
app.config['MYSQL_DATABASE_PASSWORD'] = Cred['MYSQL_DATABASE_PASSWORD']
app.config['MYSQL_DATABASE_DB'] = Cred['MYSQL_DATABASE_DB']
app.config['MYSQL_DATABASE_HOST'] = Cred['MYSQL_DATABASE_HOST']

mysql.init_app(app)
db_connection = mysql.connect()

NUMS = ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9')


def query_grade_aggs(**c_id):
    query = 'SELECT * FROM grade_aggregates;'
    arg = None
    if ('c_id' in c_id):
Exemplo n.º 5
0
import user
import config

app = user.create_app(config)
if __name__ == '__main__':
    app.run(host='localhost', port=5000, debug=True)
Exemplo n.º 6
0
import os
from flask_migrate import Migrate
# from user import db, create_app
from user import db, create_app

app = create_app(os.getenv('FLASK_CONFIG') or 'default')
migrate = Migrate(app, db)