简体   繁体   English

在调试模式下运行 Flask 应用程序不提供 IP 或调试器 PIN 或任何请求详细信息

[英]Running Flask app in debug mode does not provide the IP or the Debugger PIN or any Request details

I am working on a Flask app, and at first the debug mode was working as expected.我正在开发 Flask 应用程序,起初调试模式按预期工作。 It typically had an output such as "Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)" and the Request Status Codes everytime I made any changes and also provided a debugger PIN.它通常有一个 output,例如“在http://127.0.0.1:5000/上运行(按 CTRL+C 退出)”和每次我进行任何更改时的请求状态代码,还提供了调试器 PIN。 After making a few changes and re-organizing my App file structure by adding Blueprints, these details do not come up in the command line while running the App.通过添加蓝图进行一些更改并重新组织我的应用程序文件结构后,这些详细信息在运行应用程序时不会出现在命令行中。

The output is always just this output 总是这样

Serving Flask app "web_app" (lazy loading)
 * Environment: development
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on

Instead of the previous output, that contained the IP, Debugger PIN etc.而不是以前的 output,它包含 IP、调试器 PIN 等。

* Serving Flask app "app" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 139-055-956
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

I can't figure out why this is happening.The changes I made were adding Blueprints and moving a few routes into them, and the initialization of the App was made through an function.我不知道为什么会这样。我所做的更改是添加蓝图并将一些路线移动到其中,并且应用程序的初始化是通过 function 进行的。

The name of the app is "web_app"该应用程序的名称是“web_app”

My run.py我的运行.py

from web_app import create_app
app = create_app()

if __name__ == '__main__':
    app.run(debug=True)

web_app.网络应用程序。 init .py初始化.py

from flask import Flask
from web_app.config import Config
from flask_sqlalchemy import SQLAlchemy
from flask_bcrypt import Bcrypt
from flask_login import LoginManager
from flask_mail import Mail


db = SQLAlchemy()
bcrypt = Bcrypt()
login = LoginManager()
mail = Mail()

def create_app(config_class = Config):
    app = Flask(__name__)
    app.config.from_object(Config)
    db.init_app(app)
    from web_app.models import User, Retailer, Results, Watchlist
    with app.app_context():
        db.create_all()
    bcrypt.init_app(app)
    login.init_app(app)
    mail.init_app(app)
    from web_app.main.routes import main
    from web_app.posts.routes import post
    from web_app.user.routes import user
    from web_app.errors.handlers import errors
    app.register_blueprint(main)
    app.register_blueprint(post)
    app.register_blueprint(user)
    app.register_blueprint(errors)
    login.login_view = 'user.login'
    return app

config.py配置文件

import os

class Config:
    SECRET_KEY = '5ab34f90107c5d025461e91c2d6ce13d'
    SQLALCHEMY_DATABASE_URI = 'sqlite:///test1.db'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    MAIL_SERVER = 'smtp.gmail.com'
    MAIL_PORT = 587
    MAIL_USE_TLS = True
    MAIL_USERNAME = os.environ.get('EMAIL_USER')
    MAIL_PASSWORD = os.environ.get('EMAIL_PASS')

I don't know if I have provided enough info for this, please let me know if anything is required.我不知道我是否为此提供了足够的信息,如果需要任何信息,请告诉我。

Thanks in advance!提前致谢!

figured out what the issue was.找出问题所在。 One of my programs associated with this was using the built-in logging module and all the data was being logged to the log file.我与此相关的一个程序是使用内置的日志记录模块,所有数据都被记录到日志文件中。 Once I removed the log file, and changed the logging config, it started working correctly.一旦我删除了日志文件并更改了日志配置,它就开始正常工作。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM