I\'m having trouble understanding how to split a flask app into multiple files.
I\'m creating a web service and I want to split the api\'s into different files (Acco
Using Blueprint you can add your routes in the routes directory.
app.py
routes
__init__.py
index.py
users.py
from flask import Blueprint
routes = Blueprint('routes', __name__)
from .index import *
from .users import *
from flask import render_template
from . import routes
@routes.route('/')
def index():
return render_template('index.html')
from flask import render_template
from . import routes
@routes.route('/users')
def users():
return render_template('users.html')
from routes import *
app.register_blueprint(routes)
If you want to add a new route file, say accounts.py, you just need to create the file accounts.py in the routes directory, just like index.py and users.py, then import it in the routes.__init__.py file
from .accounts import *