setting.py 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. "freeProxy06",
  45. "freeProxy07",
  46. "freeProxy08",
  47. "freeProxy09",
  48. ]
  49. # # API config http://127.0.0.1:5010
  50. SERVER_API = {
  51. "HOST": "0.0.0.0", # The ip specified which starting the web API
  52. "PORT": 5010 # port number to which the server listens to
  53. }