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

jinja2.exceptions.TemplateNotFound: index.html #9

Closed
bjenmonk opened this issue Sep 6, 2021 · 28 comments
Closed

jinja2.exceptions.TemplateNotFound: index.html #9

bjenmonk opened this issue Sep 6, 2021 · 28 comments
Labels
problem Something isn't working question Further information is requested

Comments

@bjenmonk
Copy link

bjenmonk commented Sep 6, 2021

Hi
I cloned your code and while trying to use the example app I am getting this error

raise TemplateNotFound(template)

jinja2.exceptions.TemplateNotFound: index.html

I tried creating a templates folder under the example directory and copied contents from the view folder to it. still the same error

Appreciate your help

@marcuxyz
Copy link
Owner

marcuxyz commented Sep 6, 2021

Hi @bjenmonk ,

change the folder name templates to views . let me know if i helped you

@bjenmonk
Copy link
Author

bjenmonk commented Sep 6, 2021

Hi Marcuxyz
tried that but didn't worked so I fixed it by changing
def create_app():
app = Flask(name, template_folder='views')

@marcuxyz
Copy link
Owner

marcuxyz commented Sep 6, 2021

Hey :)

You dont need configure the template_folder param, because, we will make this for you

https://github.com/marcuxyz/mvc_flask/blob/0c9a463a0744ff6ca072ac2eb5cf89bd25d0504d/mvc_flask/__init__.py#L14

Please, see this image:

image

is your directory like this?

@bjenmonk
Copy link
Author

bjenmonk commented Sep 6, 2021

yes, the folder structure is like that. I removed the template_folder='views' and now it is working. not sure why. but thanks for your time

@bjenmonk bjenmonk closed this as completed Sep 6, 2021
@marcuxyz
Copy link
Owner

marcuxyz commented Sep 6, 2021

You are welcome! :)

@nand2509
Copy link

Actually, its not working still have same problem.

@Sandesh-Ghimire
Copy link

app = Flask(name) instead of this only you can write as mentioned below.

app = Flask(name, template_folder='templates')
//here templates is the folder name , check your folder name and write it inside single quotes.
this one worked for me.

@marcuxyz
Copy link
Owner

yes, the folder structure is like that. I removed the template_folder='views' and now it is working. not sure why. but thanks for your time

please shared this repository, i will go review

@marcuxyz marcuxyz reopened this Dec 26, 2022
@marcuxyz marcuxyz added question Further information is requested problem Something isn't working labels Dec 30, 2022
@kssy-ks
Copy link

kssy-ks commented Mar 23, 2023

Hi there!
To solve TEMPLATE NOT FOUND ERROR in Flask I added "template_folder". So in short you get this:

from flask import Flask, render_template

app=Flask(__name__, template_folder='template')

@app.route('/')
def main():
    return render_template('home.html')

app.run(debug=True)

@marcuxyz marcuxyz reopened this Mar 26, 2023
@marcuxyz
Copy link
Owner

Hi there! To solve TEMPLATE NOT FOUND ERROR in Flask I added "template_folder". So in short you get this:

from flask import Flask, render_template

app=Flask(__name__, template_folder='template')

@app.route('/')
def main():
    return render_template('home.html')

app.run(debug=True)

Hi @kssy-ks . Fines?
please shared this repository, i will go review.

@marcuxyz
Copy link
Owner

marcuxyz commented Apr 6, 2023

I tested here, its work for me :) see:

Captura de Tela 2023-04-05 às 23 23 12

@marcuxyz marcuxyz closed this as completed Apr 6, 2023
@Reins981
Copy link

Sorry to say but this bug is really annoying. I tried all the suggested solutions but still face the same issue

@marcuxyz
Copy link
Owner

marcuxyz commented Aug 19, 2023

Sorry to say but this bug is really annoying. I tried all the suggested solutions but still face the same issue

Can you share this repository?

@eyobmamo
Copy link

eyobmamo commented Aug 29, 2023

app = Flask(name) instead of this only you can write as mentioned below.

app = Flask(name, template_folder='templates') //here templates is the folder name , check your folder name and write it inside single quotes. this one worked for me.

i try for a hour ....it works for me!!!!!!!!!!!
thanks a lot

@marcuxyz
Copy link
Owner

marcuxyz commented Aug 30, 2023

People, if you don't to describe the issue, it's hard to understand!!!!!

PLEASE, SEND YOUR PROJECT TO GITHUB AND SHARE FOR ME

if your project isn't open source, please, create one and share.

@marcuxyz marcuxyz reopened this Aug 30, 2023
@marcuxyz marcuxyz pinned this issue Sep 26, 2023
@marcuxyz marcuxyz unpinned this issue Nov 12, 2023
@ajanujaj
Copy link

ajanujaj commented Dec 7, 2023

image

Hello @marcuxyz , I also facing the same issue
can you please help me with this.

@marcuxyz
Copy link
Owner

marcuxyz commented Dec 7, 2023

Hello @ajanujaj , It looks like it doesn't use the mvc-flask extension

@marcuxyz marcuxyz reopened this Dec 7, 2023
@MuhamadZaki
Copy link

MuhamadZaki commented Feb 25, 2024

📦app
┣ 📂resources
┃ ┣ 📂static
┃ ┃ ┣ 📂css
┃ ┃ ┃ ┣ 📜login.css
┃ ┃ ┃ ┣ 📜register.css
┃ ┃ ┃ ┗ 📜style.css
┃ ┃ ┣ 📂img
┃ ┃ ┗ 📂js
┃ ┃ ┃ ┣ 📜app.js
┃ ┃ ┃ ┣ 📜login.js
┃ ┃ ┃ ┗ 📜register.js
┃ ┗ 📂templates
┃ ┃ ┣ 📜about.html
┃ ┃ ┣ 📜index.html
┃ ┃ ┣ 📜login.html
┃ ┃ ┣ 📜register.html
┃ ┃ ┗ 📜services.html
┣ 📂__pycache__
┃ ┣ 📜app.cpython-312.pyc
┃ ┣ 📜model.cpython-312.pyc
┃ ┣ 📜routes.cpython-312.pyc
┃ ┗ 📜__init__.cpython-312.pyc
┣ 📜app.py
┣ 📜model.py
┣ 📜routes.py
┗ 📜__init__.py

Cobalah mas ireng!
in routes.py ->

               app = Flask(__name__, static_folder='resources/static', template_folder='resources/templates')

in html ->

             <link rel="stylesheet" href="{{ url_for('static', filename='css/login.css') }}"> 

             <script src="{{ url_for('static', filename='js/login.js') }}"></script>

@iankb26
Copy link

iankb26 commented May 1, 2024

Hi I having the same issue on mine . @marcuxyz can you help me
440420548_1453720012020229_5253463462240928238_n
440523839_458919010032819_8051616861470120693_n
440441369_409729901835646_629505621840532910_n

@marcuxyz
Copy link
Owner

marcuxyz commented May 2, 2024

@iankb26 you can send code to github and send me the link?
Did you leave the code structure the same as this image? #9 (comment)

@iankb26
Copy link

iankb26 commented May 2, 2024

@marcuxyz https://github.com/iankb26/User-Interface Here's the link let me know what you think and I'm trying to use mvc method like what you showed on the previcus comments. Thanks for the help marcus :) ,

@marcuxyz
Copy link
Owner

marcuxyz commented May 4, 2024

@iankb26 Have you sent the correct code? I have not found the mvc-flask library.

@thanhhungk57
Copy link

I also have the same problem, can someone help me?
https://github.com/thanhhungk57/Mongodb-connect-fastapi.git

@marcuxyz
Copy link
Owner

marcuxyz commented May 9, 2024

@thanhhungk57 this project uses the fastapi project. mvc-flask only works on Flask. https://flask.palletsprojects.com/

@supreetbajaj2004
Copy link

supreetbajaj2004 commented Jul 21, 2024

hi @marcuxyz

i am also facing the same issue i have tried everything using template folder variable changing the name of the folder but facing the same issue
Screenshot (7)
Screenshot (8)

@marcuxyz
Copy link
Owner

marcuxyz commented Jul 21, 2024

Hi @supreetbajaj2004 ,
Have you installed and used the extension: MVC-flask? In your images, it looks like that doesn't. Please visit the documentation https://marcuxyz.github.io/mvc-flask/

@supreetbajaj2004
Copy link

I will thanks for help@marcuxyz

@Reins981
Copy link

Such a long discussion for a simple bug. Why is that

@marcuxyz marcuxyz closed this as completed Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
problem Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests