Beispiel #1
0
    def schedule_api(self):
        """
        开启API
        """
        app = Flask(__name__)

        def get_conn(data):
            if not hasattr(g, 'redis'):
                g.redis = RedisClient(data)
            return g.redis

        @app.route('/')
        def index():
            return '<h2>Welcome to Proxy Pool System</h2>'

        @app.route('/random')
        def get_proxy():
            """
            Get a proxy
            :return: 随机代理
            """
            conn = get_conn(self.data)
            return conn.random()

        @app.route('/count')
        def get_counts(data):
            """
            Get the count of proxies
            :return: 代理池总量
            """
            conn = get_conn(self.data)
            return str(conn.count())
        app.run(self.data['API_HOST'], self.data['API_PORT'])
Beispiel #2
0
def main():
    try:
        s = Scheduler()
        s.run()
        app.run()
    except:
        main()
 def run_server(self):
     """
     启动 API
     """
     if not ENABLE_SERVER:
         logger.info('API 未启动')
         return
     app.run(host=API_HOST, port=API_PORT, threaded=API_THREADED)
Beispiel #4
0
 def schedule_api(self):
     """
     开启AIP
     """
     print('*'*50)
     print('开启API...')
     print('*'*50)
     app.run(API_HOST, API_PORT)
def main():
    # db = redis.Redis(host=HOST, port=PORT)
    # db.flushall()
    conn = RedisClient()
    conn.flush()
    s = Schedule()
    s.run()
    app.run(host=FLASK_HOST, port=FLASK_PORT, debug=True)
Beispiel #6
0
def main():
    """
    程序入口,运行程序
    :return:
    """

    # 实例化调度器
    s = Schedule()
    # 运行调度器
    s.run()
    # 运行flask实例
    app.run()
Beispiel #7
0
 def schedule_api(self):
     """
     开启API
     """
     app.run()
Beispiel #8
0
def main():
    try:
        app.run(API_HOST, API_PORT)
    except:
        main()
 def schedule_api(self):
     """
     开启API
     """
     app.run(API_HOST, API_PORT,debug=True)
Beispiel #10
0
 def schedule_api(self):
     print('开启API')
     app.run(port=80)
Beispiel #11
0
def main():
    s = Scheduler()
    s.run()
    app.run(host=FLASK_HOST, port=FLASK_PORT, debug=True)
Beispiel #12
0
 def schedule_api(self):
     app.run(API_HOST, API_PORT)
Beispiel #13
0
 def schedule_api(self):
     """ Open API """
     app.run(API_HOST, API_PORT)
Beispiel #14
0
def main():
    #运行一个调度器
    s = Schedule()
    s.run()
    app.run()
Beispiel #15
0
def main():
    s = Schedule()
    s.run()
    app.run(host='0.0.0.0')
Beispiel #16
0
def main():

    s = Schedule()
    s.run()
    app.run()
Beispiel #17
0
def main():
    s = Schedule()
    s.run()  # 运行调度器
    app.run(debug=True, host='0.0.0.0', port=9090)  # 运行flask应用程序
Beispiel #18
0
def main():
    #Schedule是一个调度器
    s = Schedule()
    #app是一个接口
    s.run()
    app.run()
Beispiel #19
0
 def schedule_api(self):
     """
     开启API
     """
     app.run(API_HOST, API_PORT)
Beispiel #20
0
 def scheduler_api(self):
     """
     开启API
     :return: None
     """
     app.run(settings.API_HOST, settings.API_PORT)
Beispiel #21
0
def main():
    s = Schedule()
    s.run()
    app.run(host='0.0.0.0', port=8080, debug=True)
Beispiel #22
0
 def schedule_api(self):
     """
     开启API
     """
     app.run(API_HOST, API_PORT)  # 开启flask,默认是运行localhost 5555
Beispiel #23
0
 def schedule_api(self):
     '''
     开启api
     :return:
     '''
     app.run()
 def scheduler_api(self):
     '''
     开启API
     '''
     app.run(API_HOST, API_PORT)
Beispiel #25
0
def main():
    s = Schedule()  #调度器
    s.run()  #运行调度器
    app.run()  #运行接口
Beispiel #26
0
 def schedule_api(self):
     """
     开启API
     """
     print("\033[1;30;42m 开始运行API \033[0m")
     app.run(API_HOST, API_PORT)
Beispiel #27
0
 def schedule_api(self):
     """
     开启API
     """
     app.run(API_HOST, API_PORT, threaded=True)
Beispiel #28
0
 def schedule_api(self):
     '''
     开启API
     :return:
     '''
     app.run(API_HOST,API_PORT)
Beispiel #29
0
def main():
    s = Schedule()
    s.run()
    app.run()
Beispiel #30
0
 def api(self):
     app.run(API_HOST, API_PORT)
Beispiel #31
0
 def schedule_api(self):
     """
     开启API
     :return:
     """
     app.run(API_HOST, API_PORT)
Beispiel #32
0
 def schedule_api(self):
     """
     开启API
     """
     app.run(api_host, api_port)