Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Commit

Permalink
在 settings 中统一使用字符串替代 bool 值
Browse files Browse the repository at this point in the history
  • Loading branch information
gwind committed Jan 31, 2019
1 parent 8a1f0f0 commit eed8090
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/codebase/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __init__(self):
tornado_settings = {
"xsrf_cookies": False,
"gzip": True,
"debug": settings.DEBUG,
"debug": settings.DEBUG == "true",
"secret_key": settings.SECRET_KEY,
}

Expand Down
5 changes: 3 additions & 2 deletions src/codebase/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
DEBUG = True
SYNC_DATABASE = True
DEBUG = "false"
CORS = "false"
SYNC_DATABASE = "false"

SECRET_KEY = "IpVDzxWOPQP9xxONJYdUHK1PNcyt4182Zulua6xfWkvZgp"

Expand Down
6 changes: 3 additions & 3 deletions src/codebase/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
class BaseHandler(tornado.web.RequestHandler):
def set_default_headers(self):
self.set_header("Access-Control-Allow-Origin", "*")
self.set_header("Access-Control-Allow-Headers", "x-requested-with")
self.set_header("Access-Control-Allow-Methods", "POST, GET, OPTIONS")
self.set_header("Access-Control-Allow-Headers", "*")
self.set_header("Access-Control-Allow-Methods", "*")

def options(self):
# no body
self.set_status(204)
self.finish()


if settings.DEBUG:
if settings.CORS == "true":
MainBaseHandler = BaseHandler
else:
MainBaseHandler = tornado.web.RequestHandler
Expand Down
2 changes: 1 addition & 1 deletion src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def main():
dbc.wait_for_it()

# sync database
if settings.SYNC_DATABASE:
if settings.SYNC_DATABASE == "true":
import_module(settings.MODELS_MODULE)
dbc.create_all()

Expand Down

0 comments on commit eed8090

Please sign in to comment.