Advertisement
juanmd

wsgi.py Proyecto 2 UCN

May 12th, 2022
632
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import os
  2. from django.core.wsgi import get_wsgi_application
  3. import json
  4. from django.core.exceptions import ImproperlyConfigured
  5.  
  6.  
  7. with open("global_data.json") as f:
  8.     value = json.loads(f.read())
  9.    
  10.    
  11. def get_value(value_title, values=value):
  12.     try:
  13.         return values[value_title]
  14.     except:
  15.         msg = f"The name of {value_title} doesn't exists"
  16.         raise ImproperlyConfigured(msg)
  17.  
  18.  
  19. if get_value("ENVIRONMENT") == "local":
  20.     os.environ.setdefault('DJANGO_SETTINGS_MODULE', f'{get_value("CORE_APP")}.settings.local')
  21. else:
  22.     os.environ.setdefault('DJANGO_SETTINGS_MODULE', f'{get_value("CORE_APP")}.settings.production')
  23.  
  24.  
  25. application = get_wsgi_application()
  26.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement