Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Flask Routes #130

Merged
merged 3 commits into from
Sep 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
0.18.1 - 2017-09-07
# 0.18.2 - 2017-09-07
## Added
- 🔧 Added an `endpoint` to each of the URLs to allow for multiple routes (https://github.com/plotly/dash/pull/70)

# 0.18.1 - 2017-09-07
## Fixed
- 🐛 If `app.layout` was supplied a function, then it used to be called excessively. Now it is called just once on startup and just once on page load. https://github.com/plotly/dash/pull/128

0.18.0 - 2017-09-07
# 0.18.0 - 2017-09-07
## Changed
- 🔒 Removes the `/static/` folder and endpoint that is implicitly initialized by flask. This is too implicit for my comfort level: I worry that users will not be aware that their files in their `static` folder are accessible
- ⚡️ Removes all API calls to the Plotly API (https://api.plot.ly/), the authentication endpoints and decorators, and the associated `filename`, `sharing` and `app_url` arguments. This was never documented or officially supported and authentication has been moved to the [`dash-auth` package](https://github.com/plotly/dash-auth)
Expand All @@ -11,7 +15,7 @@
## Added
- 🔧 Add two new `config` variables: `routes_pathname_prefix` and `requests_pathname_prefix` to provide more flexibility for API routing when Dash apps are run behind proxy servers. `routes_pathname_prefix` is a prefix applied to the backend routes and `requests_pathname_prefix` prefixed in requests made by Dash's front-end. `dash-renderer==0.8.0rc3` uses these endpoints.
- 🔧 Added id to KeyError exception in components (#112)
- 🔧 Added an `endpoint` to each of the URLs to allow for multiple routes


## Fixed
- ✏️ Fix a typo in an exception
Expand Down
39 changes: 20 additions & 19 deletions dash/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,43 +67,44 @@ def __init__(
self.registered_paths = {}

# urls
def add_url(name, view_func, methods=['GET']):
self.server.add_url_rule(
name,
view_func=view_func,
endpoint=name,
methods=methods
)

self.server.add_url_rule(
add_url(
'{}_dash-layout'.format(self.config.routes_pathname_prefix),
view_func=self.serve_layout)
self.serve_layout)

self.server.add_url_rule(
add_url(
'{}_dash-dependencies'.format(self.config.routes_pathname_prefix),
view_func=self.dependencies)
self.dependencies)

self.server.add_url_rule(
add_url(
'{}_dash-update-component'.format(
self.config.routes_pathname_prefix
),
view_func=self.dispatch,
methods=['POST'])
self.dispatch,
['POST'])

self.server.add_url_rule((
add_url((
'{}_dash-component-suites'
'/<string:package_name>'
'/<path:path_in_package_dist>').format(
self.config.routes_pathname_prefix
),
view_func=self.serve_component_suites)
self.serve_component_suites)

self.server.add_url_rule(
add_url(
'{}_dash-routes'.format(self.config.routes_pathname_prefix),
view_func=self.serve_routes
)

self.server.add_url_rule(
self.config.routes_pathname_prefix, view_func=self.index)
self.serve_routes)

# catch-all for front-end routes
self.server.add_url_rule(
'{}<path:path>'.format(self.config.routes_pathname_prefix),
view_func=self.index
)
add_url(
self.config.routes_pathname_prefix, self.index)

self.server.before_first_request(self._setup_server)

Expand Down
2 changes: 1 addition & 1 deletion dash/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.18.1'
__version__ = '0.18.2'