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

TypeError: expected str, bytes or os.PathLike object, not NoneType #7

Closed
mikeckennedy opened this issue Mar 11, 2021 · 2 comments
Closed
Assignees

Comments

@mikeckennedy
Copy link
Owner

From a student:

In ch4, when I try to run your main.py, I get this:

C:/Users/user/FS-FAPI/source/web-applications-with-fastapi-course/code/ch4-templates/main.py
Traceback (most recent call last):
  File "C:\Users\user\FS-FAPI\source\web-applications-with-fastapi-course\code\ch4-templates\main.py", line 7, in <module>
    from views import home
  File "C:\Users\user\FS-FAPI\source\web-applications-with-fastapi-course\code\ch4-templates\views\home.py", line 9, in <module>
    def index():
  File "C:\Users\user\FS-FAPI\venv\lib\site-packages\fastapi_chameleon\engine.py", line 72, in response_inner
    if not os.path.exists(os.path.join(template_path, template_file)):
  File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\ntpath.py", line 78, in join
    path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not NoneType

Process finished with exit code 1

Looks a timing issue between calling global init and "using" the decorator.

@mikeckennedy mikeckennedy self-assigned this Mar 11, 2021
@mikeckennedy
Copy link
Owner Author

For now, I can fix this if we default template_folder = "templates" but there should be a better long term fix for guessing template names including the folder customized in global_init(). I'm open to ideas. :)

@Cristianasp
Copy link

For now, I can fix this if we default template_folder = "templates" but there should be a better long term fix for guessing template names including the folder customized in global_init(). I'm open to ideas. :)

Mike, maybe follow the same strategy of this library?
https://fastapi-contrib.readthedocs.io/en/latest/readme.html#auto-creation-of-mongodb-indexes

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

No branches or pull requests

2 participants