Get the Django WSGI app for running PyWebIO applications. The arguments of ``wsgi_app()`` have the same meaning as for :func:`pywebio.platform.django.start_server`
(applications, cdn=True,
static_dir=None,
allowed_origins=None, check_origin=None,
session_expire_seconds=None,
session_cleanup_interval=None,
debug=False, max_payload_size='200M', **django_options)
| 102 | |
| 103 | |
| 104 | def wsgi_app(applications, cdn=True, |
| 105 | static_dir=None, |
| 106 | allowed_origins=None, check_origin=None, |
| 107 | session_expire_seconds=None, |
| 108 | session_cleanup_interval=None, |
| 109 | debug=False, max_payload_size='200M', **django_options): |
| 110 | """Get the Django WSGI app for running PyWebIO applications. |
| 111 | |
| 112 | The arguments of ``wsgi_app()`` have the same meaning as for :func:`pywebio.platform.django.start_server` |
| 113 | """ |
| 114 | global urlpatterns |
| 115 | |
| 116 | from django.conf import settings |
| 117 | from django.core.wsgi import get_wsgi_application |
| 118 | from django.urls import path |
| 119 | from django.utils.crypto import get_random_string |
| 120 | from django.views.static import serve |
| 121 | |
| 122 | cdn = cdn_validation(cdn, 'warn') |
| 123 | debug = Session.debug = os.environ.get('PYWEBIO_DEBUG', debug) |
| 124 | |
| 125 | max_payload_size = parse_file_size(max_payload_size) |
| 126 | page.MAX_PAYLOAD_SIZE = max_payload_size |
| 127 | |
| 128 | django_options.update(dict( |
| 129 | DEBUG=debug, |
| 130 | ALLOWED_HOSTS=["*"], # Disable host header validation |
| 131 | ROOT_URLCONF=__name__, # Make this module the urlconf |
| 132 | SECRET_KEY=get_random_string(10), # We aren't using any security features but Django requires this setting |
| 133 | DATA_UPLOAD_MAX_MEMORY_SIZE=max_payload_size |
| 134 | )) |
| 135 | django_options.setdefault('LOGGING', { |
| 136 | 'version': 1, |
| 137 | 'disable_existing_loggers': False, |
| 138 | 'formatters': { |
| 139 | 'simple': { |
| 140 | 'format': '[%(asctime)s] %(message)s' |
| 141 | }, |
| 142 | }, |
| 143 | 'handlers': { |
| 144 | 'console': { |
| 145 | 'class': 'logging.StreamHandler', |
| 146 | 'formatter': 'simple' |
| 147 | }, |
| 148 | }, |
| 149 | 'loggers': { |
| 150 | 'django.server': { |
| 151 | 'level': 'INFO' if debug else 'WARN', |
| 152 | 'handlers': ['console'], |
| 153 | }, |
| 154 | }, |
| 155 | }) |
| 156 | settings.configure(**django_options) |
| 157 | |
| 158 | webio_view_func = webio_view( |
| 159 | applications=applications, cdn=cdn, |
| 160 | session_expire_seconds=session_expire_seconds, |
| 161 | session_cleanup_interval=session_cleanup_interval, |
no test coverage detected
searching dependent graphs…