コード例 #1
0
def app():
    #app = init_testapp()
    app = init_app("sqlite", True)
    with app.app_context():   
        db.create_all()
        yield app   # Note that we changed return for yield, see below for why
        db.drop_all()

    #app.config.from_object('project.config.TestingConfig')
    #return app


#fixture nimeltään app. Fixture tarkoittaa asiaa joka valmistelee testiä varten pohjatilanteen
コード例 #2
0
    def setUp(self):
        super(FlaskTestCase, self).setUp()
        self.app = application.create_app("app", "config.TestingConfig")
        self.app_context = self.app.app_context()
        self.app_context.push()

        # !important must init_app after current_app is existed
        from application import init_app
        self.app = init_app(self.app)
        # !important must init_app after current_app is existed

        self.client = self.app.test_client(use_cookies=True)
        self._attach_logger_format(level = logging.DEBUG)

        # DO NOT move "import factories" from here
        import factories
        # DO NOT move "import factories" from here
        self._db = factories.init_db(self.app)
        self._create_fixtures()
コード例 #3
0
#
# CONTROLLER #####
#
import json
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand

with open('./configuration.json') as json_file:
    configuration = json.load(json_file)

from application import init_app
app = init_app(__name__)

#from paquete.codigo import objeto
#from carperta.codigopython import objeto
from module001.views import module001 as module001_blueprint
from module002.views import module002 as module002_blueprint
from module003.views import module003 as module003_blueprint

app.register_blueprint(module001_blueprint, url_prefix="/course")
app.register_blueprint(module002_blueprint, url_prefix="/board")
app.register_blueprint(module003_blueprint, url_prefix="/assignment")

# CONFIG- START
app.config['SECRET_KEY'] = configuration['SECRET_KEY']

if configuration['MODE'] == 'production':
    SQLALCHEMY_DATABASE_URI = "mysql+mysqlconnector://{username}:{password}@{hostname}/{databasename}?auth_plugin=mysql_native_password".format(
        username=configuration['mysql_username'],
        password=configuration['mysql_password'],
        hostname=configuration['mysql_hostname'],
コード例 #4
0
from dotenv import load_dotenv
load_dotenv()
import os
import requests
import urllib.parse as urlparse
from flask import (Flask, render_template, request, redirect, session, url_for,
                   make_response, jsonify)
from application import init_app, redirect

# ASETUKSET
# db_type: Jos käytetään Oraclea, anna "oracle"; muuten käytetään oletuksena SQLitea
# print_db_echo: Jos haluat tietokantatulosteet komentoriville, anna True; muuten False
db_type = "oracle"

print_db_echo = False

app = init_app(db_type, print_db_echo)

port = int(os.environ.get("PORT", 3000))

app.secret_key = 'supersecret'


@app.route('/')
def index():
    return app.send_static_file('index.html')


if __name__ == '__main__':
    app.run(debug=True, host='127.0.0.1', port=port)
コード例 #5
0
from application import db, init_app

app = init_app()


@app.cli.command("create-all")
def create_all():
    db.create_all()


@app.cli.command("drop-all")
def drop_all():
    db.drop_all()


@app.cli.command("urls")
def url_map():
    print(app.url_map)


if __name__ == "__main__":
    app.run(host="0.0.0.0")
コード例 #6
0
ファイル: main.py プロジェクト: adcwb/flask_demo
from application import init_app

# 初始化项目配置文件
manage = init_app("application.settings.dev")


@manage.app.route('/')
def index():
    return 'index'


if __name__ == '__main__':
    manage.run()
コード例 #7
0
ファイル: manage.py プロジェクト: ricardozhang1/students
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2019/7/1 10:57
# @Author  : ZhangChaowei
# @Site    :
# @File    : manage.py
# @Software: PyCharm

from application import init_app, db
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand

# 选择模式dev或者prop
app = init_app("dev")

# 使用终端脚本工具启动和管理flask
manager = Manager(app)

# 启动数据库迁移工具
Migrate(app, db)

# 添加数据迁移的命令到终端脚本工具中
manager.add_command('db', MigrateCommand)


@app.route("/")
def index():
    return "index"


if __name__ == '__main__':
コード例 #8
0
ファイル: confixtures.py プロジェクト: nonamedb/kazan_backend
def database():
    db.create_all(app=init_app())
コード例 #9
0
ファイル: main.py プロジェクト: adcwb/mofang
# from __future__ import absolute_import
from celery import Celery
from application import init_app

# 初始化celery对象
app = Celery("flask")

# 初始化flask
flask_app = init_app("application.settings.dev").app

# 加载配置
app.config_from_object("mycelery.config")
# 自动注册任务
app.autodiscover_tasks(["mycelery.sms", "mycelery.tree"])
# 运行celery
# 主程序终端下启动: celery -A mycelery.main worker -l info
# 调度器终端下启动: celery -A mycelery.main beat

コード例 #10
0
from flask.ext.script import Manager

from application import create_app
from application import init_app

app = create_app("app", "config.DevelopmentConfig")
app = init_app(app)
manager = Manager(app)

@manager.command
def init_db():
    from models import db
    db.init_app(app)
    db.create_all()

if __name__ == "__main__":
    manager.run()
コード例 #11
0
 def get_app(self):
     return application.init_app()
コード例 #12
0
#! /usr/bin/env python3
from application import init_app, db
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
# 以下这些是便于使用者第一次使用时生成表到数据库,所以不要注释掉
from flask_cors import *
from application.apps.index.models import Department, Users
from application.apps.index import api

app = init_app('dev')

# CORS(app, supports_credentials=True)
# 使用终端脚本工具启动和管理flask
manager = Manager(app)

# 启用数据迁移工具
Migrate(app, db)

# 添加数据迁移的命令到终端脚本工具中
manager.add_command('db', MigrateCommand)

if __name__ == '__main__':

    manager.run()
コード例 #13
0
ファイル: conftest.py プロジェクト: luomus/lintuasemasovellus
def app():
    app = init_app("sqlite", True)
    with app.app_context():
        db.create_all()
        yield app
        db.drop_all()
コード例 #14
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2019/9/11 20:12
# @Author  : Lin Luo
# @Site    :
# @File    : index
# @Software: PyCharm
from application import init_app

if __name__ == '__main__':
    init_app('dev').run(port=4060)