Flask处理器启动两次

2024-04-18 14:38:56 发布

您现在位置:Python中文网/ 问答频道 /正文

启动Flask时,我两次收到handler started消息,甚至在发出任何请求之前。什么是冗余流程以及如何解决此问题

 * Serving Flask app "app.py" (lazy loading)
 * Environment: development
 * Debug mode: on
 * Restarting with windowsapi reloader
------------>>> handler started
 * Debugger is active!
 * Debugger PIN: 519-729-899
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
------------>>> handler started

app.py

from flask import Flask
from flask import request
from frontend.handler import handler
   
app = Flask(__name__)
app.register_blueprint(handler)


@app.route('/flask_alive')
def requestAlive():
    return 'Flast is alive'

handler.py

from flask import Blueprint, request, jsonify, abort
import pprint
import datetime
   
handler = Blueprint('handler', __name__)
pp = pprint.PrettyPrinter(indent=4)

print('------------>>> handler started')


@handler.route('/visualcode/py/<url>', methods=['POST'])
@check_auth
def process(url):
    ...................

Tags: namefrompyimportappflaskison