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

StaticFiles directory argument should take a PathLike instead of a str #1004

Closed
kevinastone opened this issue Jul 20, 2020 · 2 comments · Fixed by #1007
Closed

StaticFiles directory argument should take a PathLike instead of a str #1004

kevinastone opened this issue Jul 20, 2020 · 2 comments · Fixed by #1007

Comments

@kevinastone
Copy link
Contributor

It would be preferable to allow the StaticFiles app to use an os.PathLike so you can also provide pathlib.Path instances. I can work on a PR if there's agreement.

@tomchristie
Copy link
Member

Sure thing, yup!

kevinastone added a commit to kevinastone/starlette that referenced this issue Jul 20, 2020
This allows using `pathlib.Path` in addition to `str` for configuring
the base directory of the static files in line with how python3.6+
handles filesystem operations.

Fixes encode#1004
kevinastone added a commit to kevinastone/starlette that referenced this issue Jul 27, 2020
This allows using `pathlib.Path` in addition to `str` for configuring
the base directory of the static files in line with how python3.6+
handles filesystem operations.

Fixes encode#1004
kevinastone added a commit to kevinastone/starlette that referenced this issue Aug 5, 2020
This allows using `pathlib.Path` in addition to `str` for configuring
the base directory of the static files in line with how python3.6+
handles filesystem operations.

Fixes encode#1004
erewok pushed a commit that referenced this issue Aug 5, 2020
* Use os.PathLike in StaticFiles for directory

This allows using `pathlib.Path` in addition to `str` for configuring
the base directory of the static files in line with how python3.6+
handles filesystem operations.

Fixes #1004

* Fixed `mimetypes.guess_type` not supporting PathLike on py3.7 and below

* Updated staticfiles documentation with `PathLike` param
@Yobmod
Copy link

Yobmod commented Sep 3, 2020

Hi, I know this is closed, but can the same be done for 'Jinja2Templates'?

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 a pull request may close this issue.

3 participants