Advertisement
Guest User

Untitled

a guest
Mar 5th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. # settings
  2.  
  3. import logging
  4. import logging.config
  5. import os
  6.  
  7.  
  8. CACHE_HOST = os.environ["CACHE_HOST"]
  9. CACHE_PORT = int(os.environ["CACHE_PORT"])
  10.  
  11. DATABASE_ENGINE = os.environ["DATABASE_ENGINE"]
  12. DATABASE_HOST = os.environ["DATABASE_HOST"]
  13. DATABASE_PORT = int(os.environ["DATABASE_PORT"])
  14. DATABASE_NAME = os.environ["DATABASE_NAME"]
  15. DATABASE_USER = os.environ["DATABASE_USER"]
  16. DATABASE_PASSWORD = os.environ["DATABASE_PASSWORD"]
  17.  
  18. DEBUG = "INPROMO_DEBUG" in os.environ
  19. LOGGING = {
  20. "version": 1,
  21. "disable_existing_loggers": False,
  22. "formatters": {
  23. "main": {
  24. "format": "%(asctime)-15s %(levelname)-8s\n" + " " * 16 + "%(message)s",
  25. },
  26. "debug": {
  27. "format": "%(asctime)-15s %(levelname)-8s %(lineno)-4s\n" + " " * 16 + "%(message)s",
  28. },
  29. },
  30. "handlers": {
  31. "main": {
  32. "class": "logging.StreamHandler",
  33. "level": "WARNING",
  34. "formatter": "main",
  35. },
  36. "debug": {
  37. "class": "logging.StreamHandler",
  38. "level": "DEBUG",
  39. "formatter": "debug",
  40. },
  41. },
  42. "loggers": {
  43. "main": {
  44. "handlers": ["main"],
  45. "propagate": True,
  46. },
  47. "debug": {
  48. "handlers": ["debug"],
  49. "propagate": True,
  50. },
  51. },
  52. }
  53.  
  54. logging.config.dictConfig(LOGGING)
  55.  
  56. # main.py
  57.  
  58. from aiohttp import web
  59. import logging
  60. from routes import routes
  61. import settings
  62.  
  63.  
  64. logger = logging.getLogger(__name__)
  65.  
  66.  
  67. if __name__ == "__main__":
  68. logger.info("Application server is starting...")
  69. app = web.Application()
  70. for path, method, view in routes:
  71. app.router.add_route(method, path, view)
  72. web.run_app(app, port=8000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement