0
I want to create a basic application, but I’m not able to render Project structure
├── Project
│ ├── Controllers
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── Models
│ │ └── Conexao
│ ├── templates
│ │ └── index.html
│ └── View
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── View_index_page.py
│ └── View_index_page.pyc
├── run.py
└── run.pyc
Run py.
from flask import Flask, Blueprint
from Project.View.View_index_page import simple_page
app = Flask(__name__)
app.register_blueprint(simple_page)
app.run(debug=True)
view py.
from flask import Blueprint, render_template,url_for
simple_page =
Blueprint('simple_page',__name__,template_folder='templates')
@simple_page.route('/')
def show():
return render_template('index.html')
The directory with the templates is saved exactly with the templates name? If possible add the structure of your project.
– Tuxpilgrim
@Tuxpilgrim Just a moment
– André Felipe Jardim Firmo
@Tuxpilgrim Ready!
– André Felipe Jardim Firmo
great! I don’t have time to write a reply, but take a look at the Blueprints doc with Flask (especially in the section on Templates), there is the exact structure of the directories, and you won’t even need to use the
template_folder
: http://flask.pocoo.org/docs/1.0/blueprints/#templates– Tuxpilgrim
@Tuxpilgrim did the same structure and still sends a message from Notfound template
– André Felipe Jardim Firmo
something else - the presence of the files ". pyc" indicates that you are using Python 2.7 - there is no point in using Python 3.7 for a new project in Flask - you are literally throwing away 10 years of language evolution, plus several essential tools that no longer support Python 2.
– jsbueno
I don’t understand, you are added a Blueprint of the file View_index_page, however Blueprint is in the file view.py the code of the view.py is the same as View_index_page ?
– carlos alberto
my logic was a bit confused, I ended up seeing that I was not registering the correct way Blueprint, tidied and worked
– André Felipe Jardim Firmo
@jsbueno I don’t know why I’m creating this "pyc" when I’m using 3.7 I don’t know if it’s because of vs code
– André Felipe Jardim Firmo
3.7 creates acquisitions ". pyc" - but they should stay inside a folder "pycache" in each folder there. ". pyc" played halfway indicates that an older version of Python is reading the file. For simple code, python 2 will not find syntax error- can rather be some vscode tool using Python 2.
– jsbueno