chg: dev: app secret key

This commit is contained in:
rachmadaniHaryono 2018-05-02 20:34:01 +08:00
parent 0a0a98479a
commit dc455b798f
2 changed files with 12 additions and 8 deletions

View File

@ -45,13 +45,17 @@ Webserver Env config
Following are available os env config available for bukuserver. Following are available os env config available for bukuserver.
+-----------------------+------------------------------+ +-----------------------+--------------------------------+
| Name (without prefix) | Value and description | | Name (without prefix) | Value and description |
+-----------------------+------------------------------+ +-----------------------+--------------------------------+
| PER_PAGE | v: [`10`]/(positive integer) | | PER_PAGE | v: [`10`]/(positive integer) |
| | | | | |
| | Bookmark entry per page. | | | Bookmark entry per page. |
+-----------------------+------------------------------+ +-----------------------+--------------------------------+
| SECRET_KEY | v: [(os.urandom(24))]/(string) |
| | |
| | Server secret key. |
+-----------------------+--------------------------------+
Note: If any invalid input given, default value will be used Note: If any invalid input given, default value will be used

View File

@ -521,7 +521,7 @@ def create_app(config_filename=None):
per_page = int(os.getenv('BUKUSERVER_PER_PAGE', DEFAULT_PER_PAGE)) per_page = int(os.getenv('BUKUSERVER_PER_PAGE', DEFAULT_PER_PAGE))
per_page = per_page if per_page > 0 else DEFAULT_PER_PAGE per_page = per_page if per_page > 0 else DEFAULT_PER_PAGE
app.config['BUKUSERVER_PER_PAGE'] = per_page app.config['BUKUSERVER_PER_PAGE'] = per_page
app.config['SECRET_KEY'] = os.getenv('BUKUSERVER_SERVER_SECRET_KEY') or os.urandom(24) app.config['SECRET_KEY'] = os.getenv('BUKUSERVER_SECRET_KEY') or os.urandom(24)
bukudb = BukuDb() bukudb = BukuDb()
app.app_context().push() app.app_context().push()
setattr(flask.g, 'bukudb', bukudb) setattr(flask.g, 'bukudb', bukudb)