Changeset View
Changeset View
Standalone View
Standalone View
swh/web/ui/main.py
# Copyright (C) 2015 The Software Heritage developers | # Copyright (C) 2015 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU Affero General Public License version 3, or any later version | # License: GNU Affero General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import logging | import logging | ||||
import os | import os | ||||
from flask.ext.api import FlaskAPI | from flask.ext.api import FlaskAPI | ||||
from swh.core import config | from swh.core import config | ||||
from swh.web.ui.renderers import RENDERERS, urlize_api_links | from swh.web.ui.renderers import RENDERERS, urlize_api_links | ||||
from swh.web.ui.renderers import safe_docstring_display | from swh.web.ui.renderers import safe_docstring_display | ||||
from swh.web.ui.renderers import revision_id_from_url | |||||
from swh.storage import get_storage | from swh.storage import get_storage | ||||
DEFAULT_CONFIG = { | DEFAULT_CONFIG = { | ||||
'storage_args': ('list[str]', ['http://localhost:5000/']), | 'storage_args': ('list[str]', ['http://localhost:5000/']), | ||||
'storage_class': ('str', 'remote_storage'), | 'storage_class': ('str', 'remote_storage'), | ||||
'log_dir': ('string', '/tmp/swh/log'), | 'log_dir': ('string', '/tmp/swh/log'), | ||||
'debug': ('bool', None), | 'debug': ('bool', None), | ||||
'host': ('string', '127.0.0.1'), | 'host': ('string', '127.0.0.1'), | ||||
'port': ('int', 6543), | 'port': ('int', 6543), | ||||
'secret_key': ('string', 'development key'), | 'secret_key': ('string', 'development key'), | ||||
'max_upload_size': ('int', 16 * 1024 * 1024), | 'max_upload_size': ('int', 16 * 1024 * 1024), | ||||
'upload_folder': ('string', '/tmp/swh-web-ui/uploads'), | 'upload_folder': ('string', '/tmp/swh-web-ui/uploads'), | ||||
'upload_allowed_extensions': ('list[str]', []) # means all are accepted | 'upload_allowed_extensions': ('list[str]', []) # means all are accepted | ||||
} | } | ||||
# api's definition | # api's definition | ||||
app = FlaskAPI(__name__) | app = FlaskAPI(__name__) | ||||
app.jinja_env.filters['urlize_api_links'] = urlize_api_links | app.jinja_env.filters['urlize_api_links'] = urlize_api_links | ||||
app.jinja_env.filters['safe_docstring_display'] = safe_docstring_display | app.jinja_env.filters['safe_docstring_display'] = safe_docstring_display | ||||
app.jinja_env.filters['revision_id_from_url'] = revision_id_from_url | |||||
AUTODOC_ENDPOINT_INSTALLED = False | AUTODOC_ENDPOINT_INSTALLED = False | ||||
def read_config(config_file): | def read_config(config_file): | ||||
"""Read the configuration file `config_file`, update the app with | """Read the configuration file `config_file`, update the app with | ||||
parameters (secret_key, conf) and return the parsed configuration as a | parameters (secret_key, conf) and return the parsed configuration as a | ||||
dict""" | dict""" | ||||
▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines |