setting.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # -*- coding: utf-8 -*-
  2. """
  3. -------------------------------------------------
  4. File Name: setting.py
  5. Description : 配置文件
  6. Author : JHao
  7. date: 2019/2/15
  8. -------------------------------------------------
  9. Change Activity:
  10. 2019/2/15:
  11. -------------------------------------------------
  12. """
  13. # database config
  14. from os import getenv
  15. class ConfigError(BaseException):
  16. pass
  17. DB_TYPE = getenv('db_type', 'SSDB')
  18. if DB_TYPE == 'SSDB':
  19. DB_HOST = getenv('ssdb_host', '127.0.0.1')
  20. DB_PORT = getenv('ssdb_port', '6379')
  21. DB_PASSWORD = getenv('ssdb_password', '')
  22. elif DB_TYPE == 'MONGODB':
  23. DB_HOST = getenv('mongodb_host', '127.0.0.1')
  24. DB_PORT = getenv('mongodb_host', '27017')
  25. DB_PASSWORD = getenv('mongodb_password', '')
  26. else:
  27. raise ConfigError('Unknown database type, your environment variable `db_type` should be one of SSDB/MONGODB.')
  28. DATABASES = {
  29. "default": {
  30. "TYPE": DB_TYPE, # TYPE SSDB/MONGODB if use redis, only modify the host port, the type should be SSDB
  31. "HOST": DB_HOST,
  32. "PORT": DB_PORT,
  33. "NAME": "proxy",
  34. "PASSWORD": DB_PASSWORD
  35. }
  36. }
  37. # register the proxy getter function
  38. PROXY_GETTER = [
  39. "freeProxy01",
  40. "freeProxy02",
  41. # "freeProxyThird", # 网站已不能访问
  42. "freeProxyFourth",
  43. "freeProxyFifth",
  44. # "freeProxySixth" # 不再提供免费代理
  45. "freeProxySeventh",
  46. # "freeProxyEight",
  47. # "freeProxyNinth",
  48. "freeProxyTen",
  49. "freeProxyEleven",
  50. "freeProxyTwelve",
  51. # foreign website, outside the wall
  52. # "freeProxyWallFirst",
  53. # "freeProxyWallSecond",
  54. # "freeProxyWallThird"
  55. ]
  56. # # API config http://127.0.0.1:5010
  57. SERVER_API = {
  58. "HOST": "0.0.0.0", # The ip specified which starting the web API
  59. "PORT": 5010 # port number to which the server listens to
  60. }