Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # settings
- import logging
- import logging.config
- import os
- CACHE_HOST = os.environ["CACHE_HOST"]
- CACHE_PORT = int(os.environ["CACHE_PORT"])
- DATABASE_ENGINE = os.environ["DATABASE_ENGINE"]
- DATABASE_HOST = os.environ["DATABASE_HOST"]
- DATABASE_PORT = int(os.environ["DATABASE_PORT"])
- DATABASE_NAME = os.environ["DATABASE_NAME"]
- DATABASE_USER = os.environ["DATABASE_USER"]
- DATABASE_PASSWORD = os.environ["DATABASE_PASSWORD"]
- DEBUG = "INPROMO_DEBUG" in os.environ
- LOGGING = {
- "version": 1,
- "disable_existing_loggers": False,
- "formatters": {
- "main": {
- "format": "%(asctime)-15s %(levelname)-8s\n" + " " * 16 + "%(message)s",
- },
- "debug": {
- "format": "%(asctime)-15s %(levelname)-8s %(lineno)-4s\n" + " " * 16 + "%(message)s",
- },
- },
- "handlers": {
- "main": {
- "class": "logging.StreamHandler",
- "level": "WARNING",
- "formatter": "main",
- },
- "debug": {
- "class": "logging.StreamHandler",
- "level": "DEBUG",
- "formatter": "debug",
- },
- },
- "loggers": {
- "main": {
- "handlers": ["main"],
- "propagate": True,
- },
- "debug": {
- "handlers": ["debug"],
- "propagate": True,
- },
- },
- }
- logging.config.dictConfig(LOGGING)
- # main.py
- from aiohttp import web
- import logging
- from routes import routes
- import settings
- logger = logging.getLogger(__name__)
- if __name__ == "__main__":
- logger.info("Application server is starting...")
- app = web.Application()
- for path, method, view in routes:
- app.router.add_route(method, path, view)
- web.run_app(app, port=8000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement