예제 #1
0
from flask_limiter import Limiter, HEADERS
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.cache import Cache

from config import Production
from my_logger import debug_logging, online_logging, access_logging


app = Flask(__name__)
app.config.from_object(Production())

db = SQLAlchemy(app)

cache = Cache(app, config={'CACHE_TYPE': 'simple'})

debug_logging(u'logs/error.log')
access_logging(u'logs/access.log')

logger = logging.getLogger('root')
access_logger = logging.getLogger('access')

limiter = Limiter(app, headers_enabled=True, global_limits=["10/minute"])
limiter.header_mapping = {
    HEADERS.LIMIT: "X-RateLimit-Limit",
    HEADERS.RESET: "X-RateLimit-Reset",
    HEADERS.REMAINING: "X-RateLimit-Remaining"
}

from .views import home, token, user, gd_vehicle, hz_hbc

app.register_blueprint(home.blueprint, url_prefix='/')
예제 #2
0
# -*- coding: utf-8 -*-
import os
import time
import json
#import shutil

import requests
import grequests

import helper
from ini_conf import MyIni
from my_logger import debug_logging

debug_logging(u'logs/error.log')

logger = logging.getLogger('root')

class HbcCompare(object):

    def __init__(self):
        self.myini = MyIni()
        self.hbc_conf = self.myini.get_hbc()
        self.kakou_ini = {'host': '10.47.187.165', 'port': 80}
        self.cgs_ini = {'host': '10.47.222.45', 'port': 8080,
                        'username':'******', 'password': '******',
                        'token': 'eyJhbGciOiJIUzI1NiIsImV4cCI6MTQ0MzI1NjcyMiwiaWF0IjoxNDQzMjQ5NTIyfQ.eyJzY29wZSI6WyJzY29wZV9nZXQiLCJoemhiY19nZXQiXSwidWlkIjoyM30.Qga6zksBXBu8Aq9zVBb7tsR_vQFI4A7IfzdgMvGEfrw'}
        self.hbc_ini = {'host': '10.47.222.45', 'port': 8081,
                        'username':'******', 'password': '******',
                        'token': ''}
        self.id_flag = self.hbc_conf['id_flag']
        self.step = self.hbc_conf['step']