创建文件api
from flask import Blueprint
route_api = Blueprint('api_page', __name__)
@route_api.route('/api1')
def index():
return "api1"
@route_api.route('/api2')
def heello():
return 'api2'
引入api文件
from flask import Flask
from api import route_api
app = Flask(__name__)
app.register_blueprint(route_api, url_prefix="/api")
@app.route('/')
def index():
return "index"
if __name__ == "__main__":
app.run()
将api文件注册到统一前缀api下