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. elif DB_TYPE == 'MONGODB':
  22. DB_HOST = getenv('mongodb_host', '127.0.0.1')
  23. DB_PORT = getenv('mongodb_host', '27017')
  24. else:
  25. raise ConfigError('Unknown database type, your environment variable `db_type` should be one of SSDB/MONGODB.')
  26. DATABASES = {
  27. "default": {
  28. "TYPE": DB_TYPE, # TYPE SSDB/MONGODB if use redis, only modify the host port, the type should be SSDB
  29. "HOST": DB_HOST,
  30. "PORT": DB_PORT,
  31. "NAME": "proxy",
  32. "PASSWORD": ""
  33. }
  34. }
  35. # register the proxy getter function
  36. PROXY_GETTER = [
  37. "freeProxyFirst",
  38. "freeProxySecond",
  39. # "freeProxyThird", # 网站已不能访问
  40. "freeProxyFourth",
  41. "freeProxyFifth",
  42. # "freeProxySixth" # 不再提供免费代理
  43. "freeProxySeventh",
  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. }