python类config()的实例源码

models.py 文件源码 项目:bucket_api 作者: jokamjohn 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def __init__(self, email, password):
        self.email = email
        self.password = bcrypt.generate_password_hash(password, app.config.get('BCRYPT_LOG_ROUNDS')) \
            .decode('utf-8')
        self.registered_on = datetime.datetime.now()
test_config.py 文件源码 项目:bucket_api 作者: jokamjohn 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def create_app(self):
        """
        Create an app with the development configuration
        :return:
        """
        app.config.from_object('app.config.DevelopmentConfig')
        return app
test_config.py 文件源码 项目:bucket_api 作者: jokamjohn 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def create_app(self):
        """
        Create an instance of the app with the testing configuration
        :return:
        """
        app.config.from_object('app.config.TestingConfig')
        return app
views.py 文件源码 项目:podofo 作者: VieVie31 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def search_page():
    query = request.args.get('s')
    page  = request.args.get('p')

    if not query:
        return render_template('search.html', allow_upload=app.config['ALLOW_UPLOAD'], count_pdf=count_pdf())

    try:
        page = abs(int(page))
    except:
        page = 0

    query = query.lower()
    query = unicodedata.normalize('NFKD', query).encode('ASCII', 'ignore')
    words = query.split()[:5] #max 5 words for querying...
    words = map(secure_filename, words)
    query = " ".join(words)

    words = map(lemmatize, words)

    if not words:
        return render_template('search.html')

    rows, speed, next_button = get_results(words, page)

    if next_button:
        next_button = page + 1

    return render_template('results.html', user_request=query, rows=rows, speed=speed, next_button=next_button)
views.py 文件源码 项目:podofo 作者: VieVie31 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def upload_page():
    if not app.config['ALLOW_UPLOAD']:
        return render_template('search.html')
    return render_template('upload.html')
views.py 文件源码 项目:podofo 作者: VieVie31 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def return_pdf(pdf_name):
    try:
        return redirect(url_for('static', filename=app.config['PDF_DIR'] + secure_filename(pdf_name)))
    except:
        abort(404)
controllers.py 文件源码 项目:podofo 作者: VieVie31 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def conn_to_db(db_name):
    conn = sqlite3.connect(app.config['DB_PATH'] + db_name)
    conn.create_function('LOG', 1, math.log)
    return conn
controllers.py 文件源码 项目:podofo 作者: VieVie31 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def insert_pdf_to_db(pdf_name):
    # insert a pdf into the database and return his id
    path = app.config['PDF_DIR_LOC'] + app.config['PDF_DIR'] + pdf_name
    conn = conn_to_db('pdf.db')
    cursor = conn.execute("INSERT INTO PDF (NAME, HASH, DATE) VALUES ('{}', '{}', {})".format(
                                            pdf_name, hash_file(path), int(time())))
    conn.commit()
    pdf_id = cursor.lastrowid
    conn.close()
    return pdf_id
user.py 文件源码 项目:course_plus_server 作者: luckymore0520 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def generate_auth_token(self, expiration=36000):
        s = Serializer(app.config['SECRET_KEY'], expires_in=expiration)
        self.token = s.dumps({'id': self.id})
        return self.token
user.py 文件源码 项目:course_plus_server 作者: luckymore0520 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def verify_auth_token(token):
        s = Serializer(app.config['SECRET_KEY'])
        try:
            data = s.loads(token)
        except SignatureExpired:
            return None    # valid token, but expired
        except BadSignature:
            return None    # invalid token
        user = User.query.get(data['id'])
        return user
test_app.py 文件源码 项目:Adventure-Insecure 作者: colinnewell 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def setUp(self):
        self.db_fd, self.db_filename = tempfile.mkstemp()
        # FIXME: this isn't actually working.
        app.config['DATABASE_URI'] = 'sqlite:///' + self.db_filename
        self.app = app.test_client()
        db.create_all()
brand_attachment.py 文件源码 项目:salicapi 作者: Lafaiet 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def build_link(document):

    doc_id = document['id_arquivo']

    link_file = app.config['SALIC_BASE_URL']+'verprojetos/abrir?id=%d'%(doc_id)

    return link_file
file_attachment.py 文件源码 项目:salicapi 作者: Lafaiet 项目源码 文件源码 阅读 15 收藏 0 点赞 0 评论 0
def build_link(document):

    doc_id = document['idDocumentosAgentes']

    if document['Anexado'] == '2':
        idPronac =  document['idPronac']
        link_file = app.config['SALIC_BASE_URL']+'verprojetos/abrir-documentos-anexados?id=%d&tipo=2&idPronac=%d'%(doc_id, idPronac)

    elif document['Anexado'] == '5':
        link_file = app.config['SALIC_BASE_URL']+'verprojetos/abrir?id=%d'%(doc_id)

    else:
        link_file = ''

    return link_file
Log.py 文件源码 项目:salicapi 作者: Lafaiet 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def instantiate( cls, streamType = "SCREEN", logLevel = "INFO" ):
        try:
            logging.VERBOSE = 5
            logging.addLevelName(logging.VERBOSE, "VERBOSE")
            logging.Logger.verbose = lambda inst, msg, *args, **kwargs: inst.log(logging.VERBOSE, msg, *args, **kwargs)
            logging.verbose = lambda msg, *args, **kwargs: logging.log(logging.VERBOSE, msg, *args, **kwargs)

            cls.logger = logging.getLogger()

            if logLevel not in logging._levelNames:
                raise Exception( 'Invalid file level' )

            cls.logger.setLevel( logging._levelNames[logLevel] )

            streamType = app.config['STREAMTYPE']

            if streamType == "SCREEN":
                stream = logging.StreamHandler()
            else:
                stream = logging.FileHandler( app.config['LOGFILE'] )

            formatter = logging.Formatter( '[%(levelname)-7s - %(asctime)s] %(message)s' )
            stream.setFormatter( formatter )
            cls.logger.addHandler( stream )
        except Exception, e:
            print( 'Unable to get/set log configurations. Error: %s'%( e ) )
            cls.logger = None


    ##
    # Records a message in a file and/or displays it in the screen.
    # @param level - String containing the name of the log message.
    # @param message - String containing the message to be recorded.
    #


问题


面经


文章

微信
公众号

扫码关注公众号