We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Remove Flask-Admin
Flask-Admin was a nice stop gap solution when our UI wasn't as evolved, but at this point it's more of a liability than any benefit.

Unless someone has a good use case for keeping it, we're going to remove it in the upcoming release or the one after.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `redash/__init__.py`
Content:
```
1 import sys
2 import logging
3 import urlparse
4 import urllib
5 
6 import redis
7 from flask import Flask, current_app
8 from flask_sslify import SSLify
9 from werkzeug.contrib.fixers import ProxyFix
10 from werkzeug.routing import BaseConverter
11 from statsd import StatsClient
12 from flask_mail import Mail
13 from flask_limiter import Limiter
14 from flask_limiter.util import get_ipaddr
15 from flask_migrate import Migrate
16 
17 from redash import settings
18 from redash.query_runner import import_query_runners
19 from redash.destinations import import_destinations
20 
21 
22 __version__ = '7.0.0-beta'
23 
24 
25 import os
26 if os.environ.get("REMOTE_DEBUG"):
27     import ptvsd
28     ptvsd.enable_attach(address=('0.0.0.0', 5678))
29 
30 
31 def setup_logging():
32     handler = logging.StreamHandler(sys.stdout if settings.LOG_STDOUT else sys.stderr)
33     formatter = logging.Formatter(settings.LOG_FORMAT)
34     handler.setFormatter(formatter)
35     logging.getLogger().addHandler(handler)
36     logging.getLogger().setLevel(settings.LOG_LEVEL)
37 
38     # Make noisy libraries less noisy
39     if settings.LOG_LEVEL != "DEBUG":
40         logging.getLogger("passlib").setLevel("ERROR")
41         logging.getLogger("requests.packages.urllib3").setLevel("ERROR")
42         logging.getLogger("snowflake.connector").setLevel("ERROR")
43         logging.getLogger('apiclient').setLevel("ERROR")
44 
45 
46 def create_redis_connection():
47     logging.debug("Creating Redis connection (%s)", settings.REDIS_URL)
48     redis_url = urlparse.urlparse(settings.REDIS_URL)
49 
50     if redis_url.scheme == 'redis+socket':
51         qs = urlparse.parse_qs(redis_url.query)
52         if 'virtual_host' in qs:
53             db = qs['virtual_host'][0]
54         else:
55             db = 0
56 
57         client = redis.StrictRedis(unix_socket_path=redis_url.path, db=db)
58     else:
59         if redis_url.path:
60             redis_db = redis_url.path[1]
61         else:
62             redis_db = 0
63         # Redis passwords might be quoted with special characters
64         redis_password = redis_url.password and urllib.unquote(redis_url.password)
65         client = redis.StrictRedis(host=redis_url.hostname, port=redis_url.port, db=redis_db, password=redis_password)
66 
67     return client
68 
69 
70 setup_logging()
71 redis_connection = create_redis_connection()
72 
73 mail = Mail()
74 migrate = Migrate()
75 mail.init_mail(settings.all_settings())
76 statsd_client = StatsClient(host=settings.STATSD_HOST, port=settings.STATSD_PORT, prefix=settings.STATSD_PREFIX)
77 limiter = Limiter(key_func=get_ipaddr, storage_uri=settings.LIMITER_STORAGE)
78 
79 import_query_runners(settings.QUERY_RUNNERS)
80 import_destinations(settings.DESTINATIONS)
81 
82 from redash.version_check import reset_new_version_status
83 reset_new_version_status()
84 
85 
86 class SlugConverter(BaseConverter):
87     def to_python(self, value):
88         # This is ay workaround for when we enable multi-org and some files are being called by the index rule:
89         # for path in settings.STATIC_ASSETS_PATHS:
90         #     full_path = safe_join(path, value)
91         #     if os.path.isfile(full_path):
92         #         raise ValidationError()
93 
94         return value
95 
96     def to_url(self, value):
97         return value
98 
99 
100 def create_app(load_admin=True):
101     from redash import admin, authentication, extensions, handlers
102     from redash.handlers.webpack import configure_webpack
103     from redash.handlers import chrome_logger
104     from redash.models import db, users
105     from redash.metrics.request import provision_app
106     from redash.utils import sentry
107 
108     sentry.init()
109 
110     app = Flask(__name__,
111                 template_folder=settings.STATIC_ASSETS_PATH,
112                 static_folder=settings.STATIC_ASSETS_PATH,
113                 static_path='/static')
114 
115     # Make sure we get the right referral address even behind proxies like nginx.
116     app.wsgi_app = ProxyFix(app.wsgi_app, settings.PROXIES_COUNT)
117     app.url_map.converters['org_slug'] = SlugConverter
118 
119     if settings.ENFORCE_HTTPS:
120         SSLify(app, skips=['ping'])
121 
122     # configure our database
123     app.config['SQLALCHEMY_DATABASE_URI'] = settings.SQLALCHEMY_DATABASE_URI
124     app.config.update(settings.all_settings())
125 
126     provision_app(app)
127     db.init_app(app)
128     migrate.init_app(app, db)
129     if load_admin:
130         admin.init_admin(app)
131     mail.init_app(app)
132     authentication.init_app(app)
133     limiter.init_app(app)
134     handlers.init_app(app)
135     configure_webpack(app)
136     extensions.init_extensions(app)
137     chrome_logger.init_app(app)
138     users.init_app(app)
139 
140     return app
141
```

Path: `redash/admin.py`
Content:
```
1 from flask_admin import Admin
2 from flask_admin.base import MenuLink
3 from flask_admin.contrib.sqla import ModelView
4 from flask_admin.contrib.sqla.form import AdminModelConverter
5 from wtforms import fields
6 from wtforms.widgets import TextInput
7 
8 from redash import models
9 from redash.permissions import require_super_admin
10 from redash.utils import json_loads
11 
12 
13 class ArrayListField(fields.Field):
14     widget = TextInput()
15 
16     def _value(self):
17         if self.data:
18             return u', '.join(self.data)
19         else:
20             return u''
21 
22     def process_formdata(self, valuelist):
23         if valuelist:
24             self.data = [x.strip() for x in valuelist[0].split(',')]
25         else:
26             self.data = []
27 
28 
29 class JSONTextAreaField(fields.TextAreaField):
30     def process_formdata(self, valuelist):
31         if valuelist:
32             try:
33                 json_loads(valuelist[0])
34             except ValueError:
35                 raise ValueError(self.gettext(u'Invalid JSON'))
36             self.data = valuelist[0]
37         else:
38             self.data = ''
39 
40 
41 class BaseModelView(ModelView):
42     column_display_pk = True
43     model_form_converter = AdminModelConverter
44     form_excluded_columns = ('created_at', 'updated_at')
45 
46     @require_super_admin
47     def is_accessible(self):
48         return True
49 
50 
51 class QueryResultModelView(BaseModelView):
52     column_exclude_list = ('data',)
53 
54 
55 class QueryModelView(BaseModelView):
56     column_exclude_list = ('latest_query_data',)
57     form_excluded_columns = ('version', 'visualizations', 'alerts', 'org', 'created_at',
58                              'updated_at', 'latest_query_data', 'search_vector')
59 
60 
61 class DashboardModelView(BaseModelView):
62     column_searchable_list = ('name', 'slug')
63     column_exclude_list = ('version', )
64     form_excluded_columns = ('version', 'widgets', 'org', 'created_at', 'updated_at')
65 
66 
67 def init_admin(app):
68     admin = Admin(app, name='Redash Admin', template_mode='bootstrap3')
69 
70     admin.add_view(QueryModelView(models.Query, models.db.session))
71     admin.add_view(QueryResultModelView(models.QueryResult, models.db.session))
72     admin.add_view(DashboardModelView(models.Dashboard, models.db.session))
73     logout_link = MenuLink('Logout', '/logout', 'logout')
74 
75     for m in (models.Visualization, models.Widget, models.Event, models.Organization):
76         admin.add_view(BaseModelView(m, models.db.session))
77 
78     admin.add_link(logout_link)
79
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/redash/__init__.py b/redash/__init__.py
--- a/redash/__init__.py
+++ b/redash/__init__.py
@@ -97,8 +97,8 @@
         return value
 
 
-def create_app(load_admin=True):
-    from redash import admin, authentication, extensions, handlers
+def create_app():
+    from redash import authentication, extensions, handlers
     from redash.handlers.webpack import configure_webpack
     from redash.handlers import chrome_logger
     from redash.models import db, users
@@ -126,8 +126,6 @@
     provision_app(app)
     db.init_app(app)
     migrate.init_app(app, db)
-    if load_admin:
-        admin.init_admin(app)
     mail.init_app(app)
     authentication.init_app(app)
     limiter.init_app(app)
diff --git a/redash/admin.py b/redash/admin.py
deleted file mode 100644
--- a/redash/admin.py
+++ /dev/null
@@ -1,78 +0,0 @@
-from flask_admin import Admin
-from flask_admin.base import MenuLink
-from flask_admin.contrib.sqla import ModelView
-from flask_admin.contrib.sqla.form import AdminModelConverter
-from wtforms import fields
-from wtforms.widgets import TextInput
-
-from redash import models
-from redash.permissions import require_super_admin
-from redash.utils import json_loads
-
-
-class ArrayListField(fields.Field):
-    widget = TextInput()
-
-    def _value(self):
-        if self.data:
-            return u', '.join(self.data)
-        else:
-            return u''
-
-    def process_formdata(self, valuelist):
-        if valuelist:
-            self.data = [x.strip() for x in valuelist[0].split(',')]
-        else:
-            self.data = []
-
-
-class JSONTextAreaField(fields.TextAreaField):
-    def process_formdata(self, valuelist):
-        if valuelist:
-            try:
-                json_loads(valuelist[0])
-            except ValueError:
-                raise ValueError(self.gettext(u'Invalid JSON'))
-            self.data = valuelist[0]
-        else:
-            self.data = ''
-
-
-class BaseModelView(ModelView):
-    column_display_pk = True
-    model_form_converter = AdminModelConverter
-    form_excluded_columns = ('created_at', 'updated_at')
-
-    @require_super_admin
-    def is_accessible(self):
-        return True
-
-
-class QueryResultModelView(BaseModelView):
-    column_exclude_list = ('data',)
-
-
-class QueryModelView(BaseModelView):
-    column_exclude_list = ('latest_query_data',)
-    form_excluded_columns = ('version', 'visualizations', 'alerts', 'org', 'created_at',
-                             'updated_at', 'latest_query_data', 'search_vector')
-
-
-class DashboardModelView(BaseModelView):
-    column_searchable_list = ('name', 'slug')
-    column_exclude_list = ('version', )
-    form_excluded_columns = ('version', 'widgets', 'org', 'created_at', 'updated_at')
-
-
-def init_admin(app):
-    admin = Admin(app, name='Redash Admin', template_mode='bootstrap3')
-
-    admin.add_view(QueryModelView(models.Query, models.db.session))
-    admin.add_view(QueryResultModelView(models.QueryResult, models.db.session))
-    admin.add_view(DashboardModelView(models.Dashboard, models.db.session))
-    logout_link = MenuLink('Logout', '/logout', 'logout')
-
-    for m in (models.Visualization, models.Widget, models.Event, models.Organization):
-        admin.add_view(BaseModelView(m, models.db.session))
-
-    admin.add_link(logout_link)

{"golden_diff": "diff --git a/redash/__init__.py b/redash/__init__.py\n--- a/redash/__init__.py\n+++ b/redash/__init__.py\n@@ -97,8 +97,8 @@\n         return value\n \n \n-def create_app(load_admin=True):\n-    from redash import admin, authentication, extensions, handlers\n+def create_app():\n+    from redash import authentication, extensions, handlers\n     from redash.handlers.webpack import configure_webpack\n     from redash.handlers import chrome_logger\n     from redash.models import db, users\n@@ -126,8 +126,6 @@\n     provision_app(app)\n     db.init_app(app)\n     migrate.init_app(app, db)\n-    if load_admin:\n-        admin.init_admin(app)\n     mail.init_app(app)\n     authentication.init_app(app)\n     limiter.init_app(app)\ndiff --git a/redash/admin.py b/redash/admin.py\ndeleted file mode 100644\n--- a/redash/admin.py\n+++ /dev/null\n@@ -1,78 +0,0 @@\n-from flask_admin import Admin\n-from flask_admin.base import MenuLink\n-from flask_admin.contrib.sqla import ModelView\n-from flask_admin.contrib.sqla.form import AdminModelConverter\n-from wtforms import fields\n-from wtforms.widgets import TextInput\n-\n-from redash import models\n-from redash.permissions import require_super_admin\n-from redash.utils import json_loads\n-\n-\n-class ArrayListField(fields.Field):\n-    widget = TextInput()\n-\n-    def _value(self):\n-        if self.data:\n-            return u', '.join(self.data)\n-        else:\n-            return u''\n-\n-    def process_formdata(self, valuelist):\n-        if valuelist:\n-            self.data = [x.strip() for x in valuelist[0].split(',')]\n-        else:\n-            self.data = []\n-\n-\n-class JSONTextAreaField(fields.TextAreaField):\n-    def process_formdata(self, valuelist):\n-        if valuelist:\n-            try:\n-                json_loads(valuelist[0])\n-            except ValueError:\n-                raise ValueError(self.gettext(u'Invalid JSON'))\n-            self.data = valuelist[0]\n-        else:\n-            self.data = ''\n-\n-\n-class BaseModelView(ModelView):\n-    column_display_pk = True\n-    model_form_converter = AdminModelConverter\n-    form_excluded_columns = ('created_at', 'updated_at')\n-\n-    @require_super_admin\n-    def is_accessible(self):\n-        return True\n-\n-\n-class QueryResultModelView(BaseModelView):\n-    column_exclude_list = ('data',)\n-\n-\n-class QueryModelView(BaseModelView):\n-    column_exclude_list = ('latest_query_data',)\n-    form_excluded_columns = ('version', 'visualizations', 'alerts', 'org', 'created_at',\n-                             'updated_at', 'latest_query_data', 'search_vector')\n-\n-\n-class DashboardModelView(BaseModelView):\n-    column_searchable_list = ('name', 'slug')\n-    column_exclude_list = ('version', )\n-    form_excluded_columns = ('version', 'widgets', 'org', 'created_at', 'updated_at')\n-\n-\n-def init_admin(app):\n-    admin = Admin(app, name='Redash Admin', template_mode='bootstrap3')\n-\n-    admin.add_view(QueryModelView(models.Query, models.db.session))\n-    admin.add_view(QueryResultModelView(models.QueryResult, models.db.session))\n-    admin.add_view(DashboardModelView(models.Dashboard, models.db.session))\n-    logout_link = MenuLink('Logout', '/logout', 'logout')\n-\n-    for m in (models.Visualization, models.Widget, models.Event, models.Organization):\n-        admin.add_view(BaseModelView(m, models.db.session))\n-\n-    admin.add_link(logout_link)\n", "issue": "Remove Flask-Admin\nFlask-Admin was a nice stop gap solution when our UI wasn't as evolved, but at this point it's more of a liability than any benefit.\r\n\r\nUnless someone has a good use case for keeping it, we're going to remove it in the upcoming release or the one after.\n", "before_files": [{"content": "import sys\nimport logging\nimport urlparse\nimport urllib\n\nimport redis\nfrom flask import Flask, current_app\nfrom flask_sslify import SSLify\nfrom werkzeug.contrib.fixers import ProxyFix\nfrom werkzeug.routing import BaseConverter\nfrom statsd import StatsClient\nfrom flask_mail import Mail\nfrom flask_limiter import Limiter\nfrom flask_limiter.util import get_ipaddr\nfrom flask_migrate import Migrate\n\nfrom redash import settings\nfrom redash.query_runner import import_query_runners\nfrom redash.destinations import import_destinations\n\n\n__version__ = '7.0.0-beta'\n\n\nimport os\nif os.environ.get(\"REMOTE_DEBUG\"):\n    import ptvsd\n    ptvsd.enable_attach(address=('0.0.0.0', 5678))\n\n\ndef setup_logging():\n    handler = logging.StreamHandler(sys.stdout if settings.LOG_STDOUT else sys.stderr)\n    formatter = logging.Formatter(settings.LOG_FORMAT)\n    handler.setFormatter(formatter)\n    logging.getLogger().addHandler(handler)\n    logging.getLogger().setLevel(settings.LOG_LEVEL)\n\n    # Make noisy libraries less noisy\n    if settings.LOG_LEVEL != \"DEBUG\":\n        logging.getLogger(\"passlib\").setLevel(\"ERROR\")\n        logging.getLogger(\"requests.packages.urllib3\").setLevel(\"ERROR\")\n        logging.getLogger(\"snowflake.connector\").setLevel(\"ERROR\")\n        logging.getLogger('apiclient').setLevel(\"ERROR\")\n\n\ndef create_redis_connection():\n    logging.debug(\"Creating Redis connection (%s)\", settings.REDIS_URL)\n    redis_url = urlparse.urlparse(settings.REDIS_URL)\n\n    if redis_url.scheme == 'redis+socket':\n        qs = urlparse.parse_qs(redis_url.query)\n        if 'virtual_host' in qs:\n            db = qs['virtual_host'][0]\n        else:\n            db = 0\n\n        client = redis.StrictRedis(unix_socket_path=redis_url.path, db=db)\n    else:\n        if redis_url.path:\n            redis_db = redis_url.path[1]\n        else:\n            redis_db = 0\n        # Redis passwords might be quoted with special characters\n        redis_password = redis_url.password and urllib.unquote(redis_url.password)\n        client = redis.StrictRedis(host=redis_url.hostname, port=redis_url.port, db=redis_db, password=redis_password)\n\n    return client\n\n\nsetup_logging()\nredis_connection = create_redis_connection()\n\nmail = Mail()\nmigrate = Migrate()\nmail.init_mail(settings.all_settings())\nstatsd_client = StatsClient(host=settings.STATSD_HOST, port=settings.STATSD_PORT, prefix=settings.STATSD_PREFIX)\nlimiter = Limiter(key_func=get_ipaddr, storage_uri=settings.LIMITER_STORAGE)\n\nimport_query_runners(settings.QUERY_RUNNERS)\nimport_destinations(settings.DESTINATIONS)\n\nfrom redash.version_check import reset_new_version_status\nreset_new_version_status()\n\n\nclass SlugConverter(BaseConverter):\n    def to_python(self, value):\n        # This is ay workaround for when we enable multi-org and some files are being called by the index rule:\n        # for path in settings.STATIC_ASSETS_PATHS:\n        #     full_path = safe_join(path, value)\n        #     if os.path.isfile(full_path):\n        #         raise ValidationError()\n\n        return value\n\n    def to_url(self, value):\n        return value\n\n\ndef create_app(load_admin=True):\n    from redash import admin, authentication, extensions, handlers\n    from redash.handlers.webpack import configure_webpack\n    from redash.handlers import chrome_logger\n    from redash.models import db, users\n    from redash.metrics.request import provision_app\n    from redash.utils import sentry\n\n    sentry.init()\n\n    app = Flask(__name__,\n                template_folder=settings.STATIC_ASSETS_PATH,\n                static_folder=settings.STATIC_ASSETS_PATH,\n                static_path='/static')\n\n    # Make sure we get the right referral address even behind proxies like nginx.\n    app.wsgi_app = ProxyFix(app.wsgi_app, settings.PROXIES_COUNT)\n    app.url_map.converters['org_slug'] = SlugConverter\n\n    if settings.ENFORCE_HTTPS:\n        SSLify(app, skips=['ping'])\n\n    # configure our database\n    app.config['SQLALCHEMY_DATABASE_URI'] = settings.SQLALCHEMY_DATABASE_URI\n    app.config.update(settings.all_settings())\n\n    provision_app(app)\n    db.init_app(app)\n    migrate.init_app(app, db)\n    if load_admin:\n        admin.init_admin(app)\n    mail.init_app(app)\n    authentication.init_app(app)\n    limiter.init_app(app)\n    handlers.init_app(app)\n    configure_webpack(app)\n    extensions.init_extensions(app)\n    chrome_logger.init_app(app)\n    users.init_app(app)\n\n    return app\n", "path": "redash/__init__.py"}, {"content": "from flask_admin import Admin\nfrom flask_admin.base import MenuLink\nfrom flask_admin.contrib.sqla import ModelView\nfrom flask_admin.contrib.sqla.form import AdminModelConverter\nfrom wtforms import fields\nfrom wtforms.widgets import TextInput\n\nfrom redash import models\nfrom redash.permissions import require_super_admin\nfrom redash.utils import json_loads\n\n\nclass ArrayListField(fields.Field):\n    widget = TextInput()\n\n    def _value(self):\n        if self.data:\n            return u', '.join(self.data)\n        else:\n            return u''\n\n    def process_formdata(self, valuelist):\n        if valuelist:\n            self.data = [x.strip() for x in valuelist[0].split(',')]\n        else:\n            self.data = []\n\n\nclass JSONTextAreaField(fields.TextAreaField):\n    def process_formdata(self, valuelist):\n        if valuelist:\n            try:\n                json_loads(valuelist[0])\n            except ValueError:\n                raise ValueError(self.gettext(u'Invalid JSON'))\n            self.data = valuelist[0]\n        else:\n            self.data = ''\n\n\nclass BaseModelView(ModelView):\n    column_display_pk = True\n    model_form_converter = AdminModelConverter\n    form_excluded_columns = ('created_at', 'updated_at')\n\n    @require_super_admin\n    def is_accessible(self):\n        return True\n\n\nclass QueryResultModelView(BaseModelView):\n    column_exclude_list = ('data',)\n\n\nclass QueryModelView(BaseModelView):\n    column_exclude_list = ('latest_query_data',)\n    form_excluded_columns = ('version', 'visualizations', 'alerts', 'org', 'created_at',\n                             'updated_at', 'latest_query_data', 'search_vector')\n\n\nclass DashboardModelView(BaseModelView):\n    column_searchable_list = ('name', 'slug')\n    column_exclude_list = ('version', )\n    form_excluded_columns = ('version', 'widgets', 'org', 'created_at', 'updated_at')\n\n\ndef init_admin(app):\n    admin = Admin(app, name='Redash Admin', template_mode='bootstrap3')\n\n    admin.add_view(QueryModelView(models.Query, models.db.session))\n    admin.add_view(QueryResultModelView(models.QueryResult, models.db.session))\n    admin.add_view(DashboardModelView(models.Dashboard, models.db.session))\n    logout_link = MenuLink('Logout', '/logout', 'logout')\n\n    for m in (models.Visualization, models.Widget, models.Event, models.Organization):\n        admin.add_view(BaseModelView(m, models.db.session))\n\n    admin.add_link(logout_link)\n", "path": "redash/admin.py"}], "after_files": [{"content": "import sys\nimport logging\nimport urlparse\nimport urllib\n\nimport redis\nfrom flask import Flask, current_app\nfrom flask_sslify import SSLify\nfrom werkzeug.contrib.fixers import ProxyFix\nfrom werkzeug.routing import BaseConverter\nfrom statsd import StatsClient\nfrom flask_mail import Mail\nfrom flask_limiter import Limiter\nfrom flask_limiter.util import get_ipaddr\nfrom flask_migrate import Migrate\n\nfrom redash import settings\nfrom redash.query_runner import import_query_runners\nfrom redash.destinations import import_destinations\n\n\n__version__ = '7.0.0-beta'\n\n\nimport os\nif os.environ.get(\"REMOTE_DEBUG\"):\n    import ptvsd\n    ptvsd.enable_attach(address=('0.0.0.0', 5678))\n\n\ndef setup_logging():\n    handler = logging.StreamHandler(sys.stdout if settings.LOG_STDOUT else sys.stderr)\n    formatter = logging.Formatter(settings.LOG_FORMAT)\n    handler.setFormatter(formatter)\n    logging.getLogger().addHandler(handler)\n    logging.getLogger().setLevel(settings.LOG_LEVEL)\n\n    # Make noisy libraries less noisy\n    if settings.LOG_LEVEL != \"DEBUG\":\n        logging.getLogger(\"passlib\").setLevel(\"ERROR\")\n        logging.getLogger(\"requests.packages.urllib3\").setLevel(\"ERROR\")\n        logging.getLogger(\"snowflake.connector\").setLevel(\"ERROR\")\n        logging.getLogger('apiclient').setLevel(\"ERROR\")\n\n\ndef create_redis_connection():\n    logging.debug(\"Creating Redis connection (%s)\", settings.REDIS_URL)\n    redis_url = urlparse.urlparse(settings.REDIS_URL)\n\n    if redis_url.scheme == 'redis+socket':\n        qs = urlparse.parse_qs(redis_url.query)\n        if 'virtual_host' in qs:\n            db = qs['virtual_host'][0]\n        else:\n            db = 0\n\n        client = redis.StrictRedis(unix_socket_path=redis_url.path, db=db)\n    else:\n        if redis_url.path:\n            redis_db = redis_url.path[1]\n        else:\n            redis_db = 0\n        # Redis passwords might be quoted with special characters\n        redis_password = redis_url.password and urllib.unquote(redis_url.password)\n        client = redis.StrictRedis(host=redis_url.hostname, port=redis_url.port, db=redis_db, password=redis_password)\n\n    return client\n\n\nsetup_logging()\nredis_connection = create_redis_connection()\n\nmail = Mail()\nmigrate = Migrate()\nmail.init_mail(settings.all_settings())\nstatsd_client = StatsClient(host=settings.STATSD_HOST, port=settings.STATSD_PORT, prefix=settings.STATSD_PREFIX)\nlimiter = Limiter(key_func=get_ipaddr, storage_uri=settings.LIMITER_STORAGE)\n\nimport_query_runners(settings.QUERY_RUNNERS)\nimport_destinations(settings.DESTINATIONS)\n\nfrom redash.version_check import reset_new_version_status\nreset_new_version_status()\n\n\nclass SlugConverter(BaseConverter):\n    def to_python(self, value):\n        # This is ay workaround for when we enable multi-org and some files are being called by the index rule:\n        # for path in settings.STATIC_ASSETS_PATHS:\n        #     full_path = safe_join(path, value)\n        #     if os.path.isfile(full_path):\n        #         raise ValidationError()\n\n        return value\n\n    def to_url(self, value):\n        return value\n\n\ndef create_app():\n    from redash import authentication, extensions, handlers\n    from redash.handlers.webpack import configure_webpack\n    from redash.handlers import chrome_logger\n    from redash.models import db, users\n    from redash.metrics.request import provision_app\n    from redash.utils import sentry\n\n    sentry.init()\n\n    app = Flask(__name__,\n                template_folder=settings.STATIC_ASSETS_PATH,\n                static_folder=settings.STATIC_ASSETS_PATH,\n                static_path='/static')\n\n    # Make sure we get the right referral address even behind proxies like nginx.\n    app.wsgi_app = ProxyFix(app.wsgi_app, settings.PROXIES_COUNT)\n    app.url_map.converters['org_slug'] = SlugConverter\n\n    if settings.ENFORCE_HTTPS:\n        SSLify(app, skips=['ping'])\n\n    # configure our database\n    app.config['SQLALCHEMY_DATABASE_URI'] = settings.SQLALCHEMY_DATABASE_URI\n    app.config.update(settings.all_settings())\n\n    provision_app(app)\n    db.init_app(app)\n    migrate.init_app(app, db)\n    mail.init_app(app)\n    authentication.init_app(app)\n    limiter.init_app(app)\n    handlers.init_app(app)\n    configure_webpack(app)\n    extensions.init_extensions(app)\n    chrome_logger.init_app(app)\n    users.init_app(app)\n\n    return app\n", "path": "redash/__init__.py"}, {"content": null, "path": "redash/admin.py"}]}