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

Fix landing page URL #519

Merged
merged 5 commits into from
Sep 24, 2020
Merged

Fix landing page URL #519

merged 5 commits into from
Sep 24, 2020

Conversation

shyamd
Copy link
Contributor

@shyamd shyamd commented Sep 24, 2020

This should fix the endpoint URLs on the landing page to use the proper base_url rather than what comes in from the request.

EDIT: clearly the commit names are screwed up. One is for fixing the landing page and the other ensures get_base_url returns consistent base URLs without the trailing slash.

Closes #371.

@codecov
Copy link

codecov bot commented Sep 24, 2020

Codecov Report

Merging #519 into master will decrease coverage by 0.04%.
The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #519      +/-   ##
==========================================
- Coverage   91.55%   91.51%   -0.05%     
==========================================
  Files          62       62              
  Lines        3127     3123       -4     
==========================================
- Hits         2863     2858       -5     
- Misses        264      265       +1     
Flag Coverage Δ
#project 91.51% <85.71%> (-0.05%) ⬇️
#validator 63.68% <80.95%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
optimade/server/exception_handlers.py 82.81% <ø> (ø)
optimade/server/routers/index_info.py 100.00% <ø> (ø)
optimade/server/routers/info.py 95.65% <ø> (-0.51%) ⬇️
optimade/server/routers/landing.py 70.58% <60.00%> (+1.83%) ⬆️
optimade/server/routers/utils.py 96.99% <88.88%> (-0.74%) ⬇️
optimade/server/middleware.py 94.93% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7bc4596...09ed18c. Read the comment docs.

@CasperWA
Copy link
Member

Testing this locally, using run.sh while setting OPTIMADE_BASE_URL to something weird (http://localhost:5000/test/yir), seems to make sense:
image

@CasperWA
Copy link
Member

Testing this locally, using run.sh while setting OPTIMADE_BASE_URL to something weird (http://localhost:5000/test/yir), seems to make sense:

The same is true if I add a / to the end of that env variable, i.e., OPTIMADE_BASE_URL=http://localhost:5000/test/yir/.

Of course, using run.sh the server will still run on http://localhost:5000, but the correct base URL shown on the landing page is at least what would be expected from the configuration.

CasperWA
CasperWA previously approved these changes Sep 24, 2020
Copy link
Member

@CasperWA CasperWA left a comment

Choose a reason for hiding this comment

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

Cheers @shyamd

I wonder if the utility function get_base_url should support both parsed url instances as well as str, parsing it in the function itself... It would probably remove a couple of lines in the code overall - perhaps? But this can be done in another PR.

Instead of parseing the `request.url` using urllib, simply use
`request.url`, which is a `starlette.datastructures.URL` that is similar
to a `ParsedUrl` from `urllib`.
Copy link
Member

@ml-evs ml-evs left a comment

Choose a reason for hiding this comment

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

This LGTM, thanks @shyamd and @CasperWA

@CasperWA CasperWA merged commit 5f054cc into master Sep 24, 2020
@CasperWA CasperWA deleted the fix-landing-page-url branch September 24, 2020 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Landing page wrong URL
3 participants