Jun-01-2019, 04:20 PM
I am getting the html error 404 and I don'y know why. I set it up as follows -
FlaskBlog
|
|--main
| |--__init__.py
|
|--posts
| |--__init__.py
| |--forms.py
|
|--static
| |--a css file and directory full of pictures
|
|--Templates
| |--A ton of html templates
|
|--users
| |--__init__.py
| |--forms.py
| |--utils.py
|
|--__init__.py
|--models.py
|--site.db
run.pyHere is the code for run.pyfrom flaskblog import create_app
app = create_app()
if __name__ == '__main__':
app.run(debug=True)The code for flaskblog.__init__from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_bcrypt import Bcrypt as bc
from flask_login import LoginManager
from flask_mail import Mail
import os
db = SQLAlchemy()
bc = bc()
login_manager = LoginManager()
login_manager.login_view = 'users.login'
login_manager.login_message_category = 'info'
mail = Mail()
def create_app():
app = Flask(__name__)
SECRET_KEY = os.environ.get('SECRET_KEY')
SQLALCHEMY_DATABASE_URI = os.environ.get('SQLALCHEMY_DATABASE_URI')
MAIL_SERVER = 'smtp.googlemail.com'
MAIL_PORT = 587
MAIL_USE_TLS = True
MAIL_USERNAME = os.environ.get('EMAIL_USER')
MAIL_PASSWORD = os.environ.get('EMAIL_PASS')
db.init_app(app)
bc.init_app(app)
login_manager.init_app(app)
mail.init_app(app)
from flaskblog import main
from flaskblog import users
from flaskblog import post
main.add_routes(app)
users.add_routes(app)
post.add_routes(app)
return appIn the main, users, and post folders, each of their __init__ functions has a function call add_routes which take the parameter app. The function creates a blueprint, creates routes with the blueprint, and then registers it at the end of the code. the forms are just forms for filling out specific things. and utils has send_mail and save_picture in it. models contains the User and Post class, children to db.Model. Thanks in advance for your help.
