setting.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. "freeProxy03",
  42. "freeProxy04",
  43. "freeProxy05",
  44. # "freeProxyEight",
  45. # "freeProxyNinth",
  46. "freeProxyTen",
  47. "freeProxyEleven",
  48. "freeProxyTwelve",
  49. # foreign website, outside the wall
  50. # "freeProxyWallFirst",
  51. # "freeProxyWallSecond",
  52. # "freeProxyWallThird"
  53. ]
  54. # # API config http://127.0.0.1:5010
  55. SERVER_API = {
  56. "HOST": "0.0.0.0", # The ip specified which starting the web API
  57. "PORT": 5010 # port number to which the server listens to
  58. }