We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Server is not found locally after #4643
**I'm submitting a ...**  (check one with "x")
- [x] bug report
- [ ] feature request
- [ ] support request => Please do not submit support requests here, instead ask your query in out Gitter channel at https://gitter.im/fossasia/open-event-server

After #4643, the server cannot be accessed via the URL `localhost:5000` or any other means. This has lead to Travis build failing and inability to test things locally as well. Revert this behaviour and reopen the original issue

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `config.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 import os
3 from envparse import env
4 
5 env.read_envfile()
6 
7 basedir = os.path.abspath(os.path.dirname(__file__))
8 
9 VERSION_NAME = '2.0.0-alpha.1'
10 
11 LANGUAGES = {
12     'en': 'English',
13     'bn': 'Bengali/Bangla',
14     'zh_Hans': 'Chinese (Simplified)',
15     'zh_Hant': 'Chinese (Traditional)',
16     'fr': 'French',
17     'de': 'German',
18     'id': 'Indonesian',
19     'ko': 'Korean',
20     'pl': 'Polish',
21     'es': 'Spanish',
22     'th': 'Thai',
23     'vi': 'Vietnamese',
24     'hi': 'Hindi',
25     'ja': 'Japanese',
26     'ru': 'Russian',
27 }
28 
29 
30 class Config(object):
31     """
32     The base configuration option. Contains the defaults.
33     """
34 
35     DEBUG = False
36 
37     DEVELOPMENT = False
38     STAGING = False
39     PRODUCTION = False
40     TESTING = False
41 
42     CACHING = False
43     PROFILE = False
44     SQLALCHEMY_RECORD_QUERIES = False
45 
46     FLASK_ADMIN_SWATCH = 'lumen'
47 
48     VERSION = VERSION_NAME
49     SQLALCHEMY_TRACK_MODIFICATIONS = True
50     ERROR_404_HELP = False
51     CSRF_ENABLED = True
52     SERVER_NAME = env('SERVER_NAME', default='127.0.0.1:5000')
53     FALLBACK_PORT = 80
54     CORS_HEADERS = 'Content-Type'
55     SQLALCHEMY_DATABASE_URI = env('DATABASE_URL', default=None)
56     SERVE_STATIC = env.bool('SERVE_STATIC', default=False)
57     DATABASE_QUERY_TIMEOUT = 0.1
58     SENTRY_DSN = env('SENTRY_DSN', default=None)
59     ENABLE_ELASTICSEARCH = env.bool('ENABLE_ELASTICSEARCH', default=False)
60     ELASTICSEARCH_HOST = env('ELASTICSEARCH_HOST', default='localhost:9200')
61     REDIS_URL = env('REDIS_URL', default='redis://localhost:6379/0')
62 
63     # API configs
64     SOFT_DELETE = True
65     PROPOGATE_ERROR = env.bool('PROPOGATE_ERROR', default=False)
66     DASHERIZE_API = True
67     API_PROPOGATE_UNCAUGHT_EXCEPTIONS = env.bool('API_PROPOGATE_UNCAUGHT_EXCEPTIONS', default=True)
68     ETAG = True
69 
70     if not SQLALCHEMY_DATABASE_URI:
71         print('`DATABASE_URL` either not exported or empty')
72         exit()
73 
74     BASE_DIR = basedir
75     FORCE_SSL = os.getenv('FORCE_SSL', 'no') == 'yes'
76 
77     if SERVE_STATIC:
78         UPLOADS_FOLDER = BASE_DIR + '/static/uploads/'
79         TEMP_UPLOADS_FOLDER = BASE_DIR + '/static/uploads/temp/'
80         UPLOAD_FOLDER = UPLOADS_FOLDER
81         STATIC_URL = '/static/'
82         STATIC_ROOT = 'staticfiles'
83         STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),)
84 
85     if FORCE_SSL:
86         PREFERRED_URL_SCHEME = 'https'
87 
88 
89 class ProductionConfig(Config):
90     """
91     The configuration for a production environment
92     """
93 
94     MINIFY_PAGE = True
95     PRODUCTION = True
96     CACHING = True
97 
98     # if force on
99 
100 
101 class StagingConfig(ProductionConfig):
102     """
103     The configuration for a staging environment
104     """
105 
106     PRODUCTION = False
107     STAGING = True
108 
109 
110 class DevelopmentConfig(Config):
111     """
112     The configuration for a development environment
113     """
114 
115     DEVELOPMENT = True
116     DEBUG = True
117     CACHING = True
118     PROPOGATE_ERROR = True
119 
120     # Test database performance
121     SQLALCHEMY_RECORD_QUERIES = True
122 
123 
124 class TestingConfig(Config):
125     """
126     The configuration for a test suit
127     """
128     TESTING = True
129     CELERY_ALWAYS_EAGER = True
130     CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
131     SQLALCHEMY_RECORD_QUERIES = True
132     DEBUG_TB_ENABLED = False
133     BROKER_BACKEND = 'memory'
134     SQLALCHEMY_DATABASE_URI = env('TEST_DATABASE_URL', default=None)
135     PROPOGATE_ERROR = True
136
```

Path: `manage.py`
Content:
```
1 from __future__ import print_function
2 from flask_script import Server
3 import os
4 
5 from app.api.helpers.db import save_to_db
6 from app.models.event import Event, get_new_event_identifier
7 from app import manager
8 from app import current_app as app
9 from app.models import db
10 from app.models.speaker import Speaker
11 from populate_db import populate
12 from flask_migrate import stamp
13 from sqlalchemy.engine import reflection
14 
15 from tests.unittests.auth_helper import create_super_admin
16 
17 
18 @manager.command
19 def list_routes():
20     import urllib
21 
22     output = []
23     for rule in app.url_map.iter_rules():
24         methods = ','.join(rule.methods)
25         line = urllib.unquote("{:50s} {:20s} {}".format(
26             rule.endpoint, methods, rule))
27         output.append(line)
28 
29     for line in sorted(output):
30         print(line)
31 
32 
33 @manager.command
34 def add_event_identifier():
35     events = Event.query.all()
36     for event in events:
37         event.identifier = get_new_event_identifier()
38         save_to_db(event)
39 
40 
41 @manager.option('-e', '--event', help='Event ID. Eg. 1')
42 def fix_speaker_images(event):
43     from app.helpers.sessions_speakers.speakers import speaker_image_sizes
44     from app.helpers.sessions_speakers.speakers import save_resized_photo
45     import urllib
46     from app.helpers.storage import generate_hash
47     event_id = int(event)
48     image_sizes = speaker_image_sizes()
49     speakers = Speaker.query.filter_by(event_id=event_id).all()
50     for speaker in speakers:
51         if speaker.photo and speaker.photo.strip() != '':
52             file_relative_path = 'static/media/temp/' + generate_hash(str(speaker.id)) + '.jpg'
53             file_path = app.config['BASE_DIR'] + '/' + file_relative_path
54             urllib.urlretrieve(speaker.photo, file_path)
55             speaker.small = save_resized_photo(file_path, event_id, speaker.id, 'small', image_sizes)
56             speaker.thumbnail = save_resized_photo(file_path, event_id, speaker.id, 'thumbnail', image_sizes)
57             speaker.icon = save_resized_photo(file_path, event_id, speaker.id, 'icon', image_sizes)
58             db.session.add(speaker)
59             os.remove(file_path)
60             print("Downloaded " + speaker.photo + " into " + file_relative_path)
61         print("Processed - " + str(speaker.id))
62     db.session.commit()
63 
64 
65 @manager.option('-c', '--credentials', help='Super admin credentials. Eg. username:password')
66 def initialize_db(credentials):
67     with app.app_context():
68         populate_data = True
69         inspector = reflection.Inspector.from_engine(db.engine)
70         table_name = 'events'
71         table_names = inspector.get_table_names()
72         print("[LOG] Existing tables:")
73         print("[LOG] " + ','.join(table_names))
74         if table_name not in table_names:
75             print("[LOG] Table not found. Attempting creation")
76             try:
77                 db.create_all()
78                 stamp()
79             except:
80                 populate_data = False
81                 print("[LOG] Could not create tables. Either database does not exist or tables already created")
82             if populate_data:
83                 credentials = credentials.split(":")
84                 create_super_admin(credentials[0], credentials[1])
85                 populate()
86         else:
87             print("[LOG] Tables already exist. Skipping data population & creation.")
88 
89 
90 @manager.command
91 def prepare_kubernetes_db():
92     with app.app_context():
93         initialize_db('open_event_test_user@fossasia.org:fossasia')
94 
95 
96 if __name__ == "__main__":
97     host_port = app.config['SERVER_NAME'].split(":")
98     host = host_port[0]
99     port = int(host_port[1] if len(host_port) > 1 else app.config['FALLBACK_PORT'])
100     manager.add_command("runserver", Server(host=host, port=port))
101     manager.run()
102
```
--- 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/config.py b/config.py
--- a/config.py
+++ b/config.py
@@ -49,8 +49,7 @@
     SQLALCHEMY_TRACK_MODIFICATIONS = True
     ERROR_404_HELP = False
     CSRF_ENABLED = True
-    SERVER_NAME = env('SERVER_NAME', default='127.0.0.1:5000')
-    FALLBACK_PORT = 80
+    SERVER_NAME = env('SERVER_NAME', default=None)
     CORS_HEADERS = 'Content-Type'
     SQLALCHEMY_DATABASE_URI = env('DATABASE_URL', default=None)
     SERVE_STATIC = env.bool('SERVE_STATIC', default=False)
diff --git a/manage.py b/manage.py
--- a/manage.py
+++ b/manage.py
@@ -1,5 +1,4 @@
 from __future__ import print_function
-from flask_script import Server
 import os
 
 from app.api.helpers.db import save_to_db
@@ -94,8 +93,4 @@
 
 
 if __name__ == "__main__":
-    host_port = app.config['SERVER_NAME'].split(":")
-    host = host_port[0]
-    port = int(host_port[1] if len(host_port) > 1 else app.config['FALLBACK_PORT'])
-    manager.add_command("runserver", Server(host=host, port=port))
     manager.run()

{"golden_diff": "diff --git a/config.py b/config.py\n--- a/config.py\n+++ b/config.py\n@@ -49,8 +49,7 @@\n     SQLALCHEMY_TRACK_MODIFICATIONS = True\n     ERROR_404_HELP = False\n     CSRF_ENABLED = True\n-    SERVER_NAME = env('SERVER_NAME', default='127.0.0.1:5000')\n-    FALLBACK_PORT = 80\n+    SERVER_NAME = env('SERVER_NAME', default=None)\n     CORS_HEADERS = 'Content-Type'\n     SQLALCHEMY_DATABASE_URI = env('DATABASE_URL', default=None)\n     SERVE_STATIC = env.bool('SERVE_STATIC', default=False)\ndiff --git a/manage.py b/manage.py\n--- a/manage.py\n+++ b/manage.py\n@@ -1,5 +1,4 @@\n from __future__ import print_function\n-from flask_script import Server\n import os\n \n from app.api.helpers.db import save_to_db\n@@ -94,8 +93,4 @@\n \n \n if __name__ == \"__main__\":\n-    host_port = app.config['SERVER_NAME'].split(\":\")\n-    host = host_port[0]\n-    port = int(host_port[1] if len(host_port) > 1 else app.config['FALLBACK_PORT'])\n-    manager.add_command(\"runserver\", Server(host=host, port=port))\n     manager.run()\n", "issue": "Server is not found locally after #4643\n**I'm submitting a ...**  (check one with \"x\")\r\n- [x] bug report\r\n- [ ] feature request\r\n- [ ] support request => Please do not submit support requests here, instead ask your query in out Gitter channel at https://gitter.im/fossasia/open-event-server\r\n\r\nAfter #4643, the server cannot be accessed via the URL `localhost:5000` or any other means. This has lead to Travis build failing and inability to test things locally as well. Revert this behaviour and reopen the original issue\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\nimport os\nfrom envparse import env\n\nenv.read_envfile()\n\nbasedir = os.path.abspath(os.path.dirname(__file__))\n\nVERSION_NAME = '2.0.0-alpha.1'\n\nLANGUAGES = {\n    'en': 'English',\n    'bn': 'Bengali/Bangla',\n    'zh_Hans': 'Chinese (Simplified)',\n    'zh_Hant': 'Chinese (Traditional)',\n    'fr': 'French',\n    'de': 'German',\n    'id': 'Indonesian',\n    'ko': 'Korean',\n    'pl': 'Polish',\n    'es': 'Spanish',\n    'th': 'Thai',\n    'vi': 'Vietnamese',\n    'hi': 'Hindi',\n    'ja': 'Japanese',\n    'ru': 'Russian',\n}\n\n\nclass Config(object):\n    \"\"\"\n    The base configuration option. Contains the defaults.\n    \"\"\"\n\n    DEBUG = False\n\n    DEVELOPMENT = False\n    STAGING = False\n    PRODUCTION = False\n    TESTING = False\n\n    CACHING = False\n    PROFILE = False\n    SQLALCHEMY_RECORD_QUERIES = False\n\n    FLASK_ADMIN_SWATCH = 'lumen'\n\n    VERSION = VERSION_NAME\n    SQLALCHEMY_TRACK_MODIFICATIONS = True\n    ERROR_404_HELP = False\n    CSRF_ENABLED = True\n    SERVER_NAME = env('SERVER_NAME', default='127.0.0.1:5000')\n    FALLBACK_PORT = 80\n    CORS_HEADERS = 'Content-Type'\n    SQLALCHEMY_DATABASE_URI = env('DATABASE_URL', default=None)\n    SERVE_STATIC = env.bool('SERVE_STATIC', default=False)\n    DATABASE_QUERY_TIMEOUT = 0.1\n    SENTRY_DSN = env('SENTRY_DSN', default=None)\n    ENABLE_ELASTICSEARCH = env.bool('ENABLE_ELASTICSEARCH', default=False)\n    ELASTICSEARCH_HOST = env('ELASTICSEARCH_HOST', default='localhost:9200')\n    REDIS_URL = env('REDIS_URL', default='redis://localhost:6379/0')\n\n    # API configs\n    SOFT_DELETE = True\n    PROPOGATE_ERROR = env.bool('PROPOGATE_ERROR', default=False)\n    DASHERIZE_API = True\n    API_PROPOGATE_UNCAUGHT_EXCEPTIONS = env.bool('API_PROPOGATE_UNCAUGHT_EXCEPTIONS', default=True)\n    ETAG = True\n\n    if not SQLALCHEMY_DATABASE_URI:\n        print('`DATABASE_URL` either not exported or empty')\n        exit()\n\n    BASE_DIR = basedir\n    FORCE_SSL = os.getenv('FORCE_SSL', 'no') == 'yes'\n\n    if SERVE_STATIC:\n        UPLOADS_FOLDER = BASE_DIR + '/static/uploads/'\n        TEMP_UPLOADS_FOLDER = BASE_DIR + '/static/uploads/temp/'\n        UPLOAD_FOLDER = UPLOADS_FOLDER\n        STATIC_URL = '/static/'\n        STATIC_ROOT = 'staticfiles'\n        STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),)\n\n    if FORCE_SSL:\n        PREFERRED_URL_SCHEME = 'https'\n\n\nclass ProductionConfig(Config):\n    \"\"\"\n    The configuration for a production environment\n    \"\"\"\n\n    MINIFY_PAGE = True\n    PRODUCTION = True\n    CACHING = True\n\n    # if force on\n\n\nclass StagingConfig(ProductionConfig):\n    \"\"\"\n    The configuration for a staging environment\n    \"\"\"\n\n    PRODUCTION = False\n    STAGING = True\n\n\nclass DevelopmentConfig(Config):\n    \"\"\"\n    The configuration for a development environment\n    \"\"\"\n\n    DEVELOPMENT = True\n    DEBUG = True\n    CACHING = True\n    PROPOGATE_ERROR = True\n\n    # Test database performance\n    SQLALCHEMY_RECORD_QUERIES = True\n\n\nclass TestingConfig(Config):\n    \"\"\"\n    The configuration for a test suit\n    \"\"\"\n    TESTING = True\n    CELERY_ALWAYS_EAGER = True\n    CELERY_EAGER_PROPAGATES_EXCEPTIONS = True\n    SQLALCHEMY_RECORD_QUERIES = True\n    DEBUG_TB_ENABLED = False\n    BROKER_BACKEND = 'memory'\n    SQLALCHEMY_DATABASE_URI = env('TEST_DATABASE_URL', default=None)\n    PROPOGATE_ERROR = True\n", "path": "config.py"}, {"content": "from __future__ import print_function\nfrom flask_script import Server\nimport os\n\nfrom app.api.helpers.db import save_to_db\nfrom app.models.event import Event, get_new_event_identifier\nfrom app import manager\nfrom app import current_app as app\nfrom app.models import db\nfrom app.models.speaker import Speaker\nfrom populate_db import populate\nfrom flask_migrate import stamp\nfrom sqlalchemy.engine import reflection\n\nfrom tests.unittests.auth_helper import create_super_admin\n\n\n@manager.command\ndef list_routes():\n    import urllib\n\n    output = []\n    for rule in app.url_map.iter_rules():\n        methods = ','.join(rule.methods)\n        line = urllib.unquote(\"{:50s} {:20s} {}\".format(\n            rule.endpoint, methods, rule))\n        output.append(line)\n\n    for line in sorted(output):\n        print(line)\n\n\n@manager.command\ndef add_event_identifier():\n    events = Event.query.all()\n    for event in events:\n        event.identifier = get_new_event_identifier()\n        save_to_db(event)\n\n\n@manager.option('-e', '--event', help='Event ID. Eg. 1')\ndef fix_speaker_images(event):\n    from app.helpers.sessions_speakers.speakers import speaker_image_sizes\n    from app.helpers.sessions_speakers.speakers import save_resized_photo\n    import urllib\n    from app.helpers.storage import generate_hash\n    event_id = int(event)\n    image_sizes = speaker_image_sizes()\n    speakers = Speaker.query.filter_by(event_id=event_id).all()\n    for speaker in speakers:\n        if speaker.photo and speaker.photo.strip() != '':\n            file_relative_path = 'static/media/temp/' + generate_hash(str(speaker.id)) + '.jpg'\n            file_path = app.config['BASE_DIR'] + '/' + file_relative_path\n            urllib.urlretrieve(speaker.photo, file_path)\n            speaker.small = save_resized_photo(file_path, event_id, speaker.id, 'small', image_sizes)\n            speaker.thumbnail = save_resized_photo(file_path, event_id, speaker.id, 'thumbnail', image_sizes)\n            speaker.icon = save_resized_photo(file_path, event_id, speaker.id, 'icon', image_sizes)\n            db.session.add(speaker)\n            os.remove(file_path)\n            print(\"Downloaded \" + speaker.photo + \" into \" + file_relative_path)\n        print(\"Processed - \" + str(speaker.id))\n    db.session.commit()\n\n\n@manager.option('-c', '--credentials', help='Super admin credentials. Eg. username:password')\ndef initialize_db(credentials):\n    with app.app_context():\n        populate_data = True\n        inspector = reflection.Inspector.from_engine(db.engine)\n        table_name = 'events'\n        table_names = inspector.get_table_names()\n        print(\"[LOG] Existing tables:\")\n        print(\"[LOG] \" + ','.join(table_names))\n        if table_name not in table_names:\n            print(\"[LOG] Table not found. Attempting creation\")\n            try:\n                db.create_all()\n                stamp()\n            except:\n                populate_data = False\n                print(\"[LOG] Could not create tables. Either database does not exist or tables already created\")\n            if populate_data:\n                credentials = credentials.split(\":\")\n                create_super_admin(credentials[0], credentials[1])\n                populate()\n        else:\n            print(\"[LOG] Tables already exist. Skipping data population & creation.\")\n\n\n@manager.command\ndef prepare_kubernetes_db():\n    with app.app_context():\n        initialize_db('open_event_test_user@fossasia.org:fossasia')\n\n\nif __name__ == \"__main__\":\n    host_port = app.config['SERVER_NAME'].split(\":\")\n    host = host_port[0]\n    port = int(host_port[1] if len(host_port) > 1 else app.config['FALLBACK_PORT'])\n    manager.add_command(\"runserver\", Server(host=host, port=port))\n    manager.run()\n", "path": "manage.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\nimport os\nfrom envparse import env\n\nenv.read_envfile()\n\nbasedir = os.path.abspath(os.path.dirname(__file__))\n\nVERSION_NAME = '2.0.0-alpha.1'\n\nLANGUAGES = {\n    'en': 'English',\n    'bn': 'Bengali/Bangla',\n    'zh_Hans': 'Chinese (Simplified)',\n    'zh_Hant': 'Chinese (Traditional)',\n    'fr': 'French',\n    'de': 'German',\n    'id': 'Indonesian',\n    'ko': 'Korean',\n    'pl': 'Polish',\n    'es': 'Spanish',\n    'th': 'Thai',\n    'vi': 'Vietnamese',\n    'hi': 'Hindi',\n    'ja': 'Japanese',\n    'ru': 'Russian',\n}\n\n\nclass Config(object):\n    \"\"\"\n    The base configuration option. Contains the defaults.\n    \"\"\"\n\n    DEBUG = False\n\n    DEVELOPMENT = False\n    STAGING = False\n    PRODUCTION = False\n    TESTING = False\n\n    CACHING = False\n    PROFILE = False\n    SQLALCHEMY_RECORD_QUERIES = False\n\n    FLASK_ADMIN_SWATCH = 'lumen'\n\n    VERSION = VERSION_NAME\n    SQLALCHEMY_TRACK_MODIFICATIONS = True\n    ERROR_404_HELP = False\n    CSRF_ENABLED = True\n    SERVER_NAME = env('SERVER_NAME', default=None)\n    CORS_HEADERS = 'Content-Type'\n    SQLALCHEMY_DATABASE_URI = env('DATABASE_URL', default=None)\n    SERVE_STATIC = env.bool('SERVE_STATIC', default=False)\n    DATABASE_QUERY_TIMEOUT = 0.1\n    SENTRY_DSN = env('SENTRY_DSN', default=None)\n    ENABLE_ELASTICSEARCH = env.bool('ENABLE_ELASTICSEARCH', default=False)\n    ELASTICSEARCH_HOST = env('ELASTICSEARCH_HOST', default='localhost:9200')\n    REDIS_URL = env('REDIS_URL', default='redis://localhost:6379/0')\n\n    # API configs\n    SOFT_DELETE = True\n    PROPOGATE_ERROR = env.bool('PROPOGATE_ERROR', default=False)\n    DASHERIZE_API = True\n    API_PROPOGATE_UNCAUGHT_EXCEPTIONS = env.bool('API_PROPOGATE_UNCAUGHT_EXCEPTIONS', default=True)\n    ETAG = True\n\n    if not SQLALCHEMY_DATABASE_URI:\n        print('`DATABASE_URL` either not exported or empty')\n        exit()\n\n    BASE_DIR = basedir\n    FORCE_SSL = os.getenv('FORCE_SSL', 'no') == 'yes'\n\n    if SERVE_STATIC:\n        UPLOADS_FOLDER = BASE_DIR + '/static/uploads/'\n        TEMP_UPLOADS_FOLDER = BASE_DIR + '/static/uploads/temp/'\n        UPLOAD_FOLDER = UPLOADS_FOLDER\n        STATIC_URL = '/static/'\n        STATIC_ROOT = 'staticfiles'\n        STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),)\n\n    if FORCE_SSL:\n        PREFERRED_URL_SCHEME = 'https'\n\n\nclass ProductionConfig(Config):\n    \"\"\"\n    The configuration for a production environment\n    \"\"\"\n\n    MINIFY_PAGE = True\n    PRODUCTION = True\n    CACHING = True\n\n    # if force on\n\n\nclass StagingConfig(ProductionConfig):\n    \"\"\"\n    The configuration for a staging environment\n    \"\"\"\n\n    PRODUCTION = False\n    STAGING = True\n\n\nclass DevelopmentConfig(Config):\n    \"\"\"\n    The configuration for a development environment\n    \"\"\"\n\n    DEVELOPMENT = True\n    DEBUG = True\n    CACHING = True\n    PROPOGATE_ERROR = True\n\n    # Test database performance\n    SQLALCHEMY_RECORD_QUERIES = True\n\n\nclass TestingConfig(Config):\n    \"\"\"\n    The configuration for a test suit\n    \"\"\"\n    TESTING = True\n    CELERY_ALWAYS_EAGER = True\n    CELERY_EAGER_PROPAGATES_EXCEPTIONS = True\n    SQLALCHEMY_RECORD_QUERIES = True\n    DEBUG_TB_ENABLED = False\n    BROKER_BACKEND = 'memory'\n    SQLALCHEMY_DATABASE_URI = env('TEST_DATABASE_URL', default=None)\n    PROPOGATE_ERROR = True\n", "path": "config.py"}, {"content": "from __future__ import print_function\nimport os\n\nfrom app.api.helpers.db import save_to_db\nfrom app.models.event import Event, get_new_event_identifier\nfrom app import manager\nfrom app import current_app as app\nfrom app.models import db\nfrom app.models.speaker import Speaker\nfrom populate_db import populate\nfrom flask_migrate import stamp\nfrom sqlalchemy.engine import reflection\n\nfrom tests.unittests.auth_helper import create_super_admin\n\n\n@manager.command\ndef list_routes():\n    import urllib\n\n    output = []\n    for rule in app.url_map.iter_rules():\n        methods = ','.join(rule.methods)\n        line = urllib.unquote(\"{:50s} {:20s} {}\".format(\n            rule.endpoint, methods, rule))\n        output.append(line)\n\n    for line in sorted(output):\n        print(line)\n\n\n@manager.command\ndef add_event_identifier():\n    events = Event.query.all()\n    for event in events:\n        event.identifier = get_new_event_identifier()\n        save_to_db(event)\n\n\n@manager.option('-e', '--event', help='Event ID. Eg. 1')\ndef fix_speaker_images(event):\n    from app.helpers.sessions_speakers.speakers import speaker_image_sizes\n    from app.helpers.sessions_speakers.speakers import save_resized_photo\n    import urllib\n    from app.helpers.storage import generate_hash\n    event_id = int(event)\n    image_sizes = speaker_image_sizes()\n    speakers = Speaker.query.filter_by(event_id=event_id).all()\n    for speaker in speakers:\n        if speaker.photo and speaker.photo.strip() != '':\n            file_relative_path = 'static/media/temp/' + generate_hash(str(speaker.id)) + '.jpg'\n            file_path = app.config['BASE_DIR'] + '/' + file_relative_path\n            urllib.urlretrieve(speaker.photo, file_path)\n            speaker.small = save_resized_photo(file_path, event_id, speaker.id, 'small', image_sizes)\n            speaker.thumbnail = save_resized_photo(file_path, event_id, speaker.id, 'thumbnail', image_sizes)\n            speaker.icon = save_resized_photo(file_path, event_id, speaker.id, 'icon', image_sizes)\n            db.session.add(speaker)\n            os.remove(file_path)\n            print(\"Downloaded \" + speaker.photo + \" into \" + file_relative_path)\n        print(\"Processed - \" + str(speaker.id))\n    db.session.commit()\n\n\n@manager.option('-c', '--credentials', help='Super admin credentials. Eg. username:password')\ndef initialize_db(credentials):\n    with app.app_context():\n        populate_data = True\n        inspector = reflection.Inspector.from_engine(db.engine)\n        table_name = 'events'\n        table_names = inspector.get_table_names()\n        print(\"[LOG] Existing tables:\")\n        print(\"[LOG] \" + ','.join(table_names))\n        if table_name not in table_names:\n            print(\"[LOG] Table not found. Attempting creation\")\n            try:\n                db.create_all()\n                stamp()\n            except:\n                populate_data = False\n                print(\"[LOG] Could not create tables. Either database does not exist or tables already created\")\n            if populate_data:\n                credentials = credentials.split(\":\")\n                create_super_admin(credentials[0], credentials[1])\n                populate()\n        else:\n            print(\"[LOG] Tables already exist. Skipping data population & creation.\")\n\n\n@manager.command\ndef prepare_kubernetes_db():\n    with app.app_context():\n        initialize_db('open_event_test_user@fossasia.org:fossasia')\n\n\nif __name__ == \"__main__\":\n    manager.run()\n", "path": "manage.py"}]}