Skip to content

Commit

Permalink
Feature/fix reverse proxy (#435)
Browse files Browse the repository at this point in the history
* new: dev: raise error when used

* chg: dev: add info on error
  • Loading branch information
rachmadaniHaryono authored Feb 8, 2020
1 parent 5638226 commit 5a23be2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions bukuserver/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
from flask_api import exceptions, FlaskAPI, status
from flask_bootstrap import Bootstrap
from flask_paginate import Pagination, get_page_parameter, get_per_page_parameter
from flask_reverse_proxy_fix.middleware import ReverseProxyPrefixFix
try:
from flask_reverse_proxy_fix.middleware import ReverseProxyPrefixFix
except ModuleNotFoundError:
ReverseProxyPrefixFix = None
from markupsafe import Markup
import click
import flask
Expand Down Expand Up @@ -236,7 +239,10 @@ def create_app(db_file=None):
if reverse_proxy_path.endswith('/'):
print('Warning: reverse proxy path should not include trailing slash')
app.config['REVERSE_PROXY_PATH'] = reverse_proxy_path
ReverseProxyPrefixFix(app)
if ReverseProxyPrefixFix:
ReverseProxyPrefixFix(app)
else:
raise ModuleNotFoundError('Failed to import ReverseProxyPrefixFix')
bukudb = BukuDb(dbfile=app.config['BUKUSERVER_DB_FILE'])
app.app_context().push()
setattr(flask.g, 'bukudb', bukudb)
Expand Down

3 comments on commit 5a23be2

@jarun
Copy link
Owner

@jarun jarun commented on 5a23be2 Feb 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rachmadaniHaryono the previous error is gone but there's a new error only for Python 3.5. Please take a look.

@rachmadaniHaryono
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL ModuleNotFoundError is new on python3.6. i will create another pr later

https://docs.python.org/3/library/exceptions.html#ModuleNotFoundError

@jarun
Copy link
Owner

@jarun jarun commented on 5a23be2 Feb 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Please sign in to comment.