示例#1
0
文件: suite.py 项目: sliuqin/yuan
    def setUp(self):
        config = {'TESTING': True}
        config['SECRET_KEY'] = 'secret-key-for-test'

        self.db_fd, self.db_file = tempfile.mkstemp()
        config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///%s' % self.db_file

        app = create_app(config)
        self.app = app

        self.client = app.test_client()

        db.create_all()

        if hasattr(self, 'prehook'):
            self.prehook()
示例#2
0
    def setUp(self):
        config = {'TESTING': True}
        config['SECRET_KEY'] = 'secret-key-for-test'
        config['WWW_ROOT'] = 'tests/data'

        self.db_fd, self.db_file = tempfile.mkstemp()
        config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///%s' % self.db_file

        app = create_app(config)
        self.app = app

        self.client = app.test_client()

        db.create_all()

        if hasattr(self, 'prehook'):
            self.prehook()
示例#3
0
文件: manager.py 项目: souse/yuan
import os
import sys
import gevent.monkey
gevent.monkey.patch_all()

from flask.ext.script import Manager
from yuan.app import create_app
from yuan.models import Project, Package
from flask import json

ROOTDIR = os.path.abspath(os.path.dirname(__file__))
CONF = os.path.join(ROOTDIR, 'etc/config.py')
if not os.path.exists(CONF):
    CONF = os.path.join(ROOTDIR, 'conf/dev_config.py')

app = create_app(CONF)
manager = Manager(app)


@manager.command
def runserver(port=5000):
    """Runs a development server."""
    from gevent.wsgi import WSGIServer
    from werkzeug.serving import run_with_reloader
    from werkzeug.debug import DebuggedApplication

    port = int(port)

    @run_with_reloader
    def run_server():
        print('start server at: 127.0.0.1:%s' % port)
示例#4
0
# coding: utf-8

import os
import imp
import gevent.monkey
gevent.monkey.patch_all()
from yuan.app import create_app
import jieba

jieba.initialize()
application = create_app()

ROOTDIR = os.path.abspath(os.path.dirname(__file__))
HOOK = os.path.join(ROOTDIR, 'etc/hook.py')
if os.path.exists(HOOK):
    hook = imp.load_source('hook', HOOK)
    hook.main()
示例#5
0
文件: run.py 项目: xbdsky/yuan
# coding: utf-8

import gevent.monkey

gevent.monkey.patch_all()
from yuan.app import create_app

__all__ = ["app"]

app = create_app()