瀏覽代碼

Merge pull request #68 from kangnwh/master

add configuration for host ip & port
J_hao104 9 年之前
父節點
當前提交
cfc29ee29e
共有 4 個文件被更改,包括 20 次插入3 次删除
  1. 3 1
      Api/ProxyApi.py
  2. 4 0
      Config.ini
  3. 4 2
      Run/main.py
  4. 9 0
      Util/GetConfig.py

+ 3 - 1
Api/ProxyApi.py

@@ -16,6 +16,7 @@ __author__ = 'JHao'
 import sys
 import sys
 
 
 from flask import Flask, jsonify, request
 from flask import Flask, jsonify, request
+from Util.GetConfig import GetConfig
 
 
 sys.path.append('../')
 sys.path.append('../')
 
 
@@ -71,7 +72,8 @@ def get_status():
 
 
 
 
 def run():
 def run():
-    app.run(host='0.0.0.0', port=5000)
+    config = GetConfig()
+    app.run(host=config.host_ip, port=config.host_port)
 
 
 if __name__ == '__main__':
 if __name__ == '__main__':
     run()
     run()

+ 4 - 0
Config.ini

@@ -13,3 +13,7 @@ freeProxySecond = 1
 freeProxyThird  = 1
 freeProxyThird  = 1
 freeProxyFourth = 1
 freeProxyFourth = 1
 freeProxyFifth  = 1
 freeProxyFifth  = 1
+
+[HOST]
+ip = 0.0.0.0
+port = 5010

+ 4 - 2
Run/main.py

@@ -15,12 +15,13 @@ __author__ = 'JHao'
 import sys
 import sys
 from multiprocessing import Process
 from multiprocessing import Process
 
 
+
 sys.path.append('../')
 sys.path.append('../')
 
 
 from Api.ProxyApi import run as ProxyApiRun
 from Api.ProxyApi import run as ProxyApiRun
 from Schedule.ProxyValidSchedule import run as ValidRun
 from Schedule.ProxyValidSchedule import run as ValidRun
 from Schedule.ProxyRefreshSchedule import run as RefreshRun
 from Schedule.ProxyRefreshSchedule import run as RefreshRun
-
+from Util.GetConfig import GetConfig
 
 
 def run():
 def run():
     p_list = list()
     p_list = list()
@@ -30,10 +31,11 @@ def run():
     p_list.append(p2)
     p_list.append(p2)
     p3 = Process(target=RefreshRun, name='RefreshRun')
     p3 = Process(target=RefreshRun, name='RefreshRun')
     p_list.append(p3)
     p_list.append(p3)
+
     for p in p_list:
     for p in p_list:
         p.start()
         p.start()
     for p in p_list:
     for p in p_list:
         p.join()
         p.join()
 
 
 if __name__ == '__main__':
 if __name__ == '__main__':
-    run()
+   run()

+ 9 - 0
Util/GetConfig.py

@@ -49,6 +49,13 @@ class GetConfig(object):
     def proxy_getter_functions(self):
     def proxy_getter_functions(self):
         return self.config_file.options('ProxyGetter')
         return self.config_file.options('ProxyGetter')
 
 
+    @LazyProperty
+    def host_ip(self):
+        return self.config_file.get('HOST','ip')
+
+    @LazyProperty
+    def host_port(self):
+        return self.config_file.get('HOST', 'port')
 
 
 if __name__ == '__main__':
 if __name__ == '__main__':
     gg = GetConfig()
     gg = GetConfig()
@@ -57,3 +64,5 @@ if __name__ == '__main__':
     print(gg.db_host)
     print(gg.db_host)
     print(gg.db_port)
     print(gg.db_port)
     print(gg.proxy_getter_functions)
     print(gg.proxy_getter_functions)
+    print(gg.host_ip)
+    print(gg.host_port)