问题
I'm working on flask application. The route localhost:5000/user/login
is not found. All other routes are working perfectly but I don't know what's going wrong with this route! Would you help me to fix this error?
This route
localhost:5000/user/login
is available but It's saying404 not found
.
run.py
from app import app
print(app.url_map)
if __name__ == '__main__':
app.run()
bytewar / init.py
from flask import Flask, url_for, redirect
app = Flask(__name__, static_folder='static')
app.config.from_pyfile('config.py')
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy(app)
# Initilaize database in app
db.init_app(app)
from app.user.views import user_blueprint
app.register_blueprint(user_blueprint)
from app.admin.views import admin_blueprint
app.register_blueprint(admin_blueprint, url_prefix='/admin')
from flask_bootstrap import Bootstrap
bootstrap = Bootstrap(app)
from flask import render_template
from flask_login import LoginManager
login_manager = LoginManager(app)
login_manager.init_app(app)
login_manager.session_protection = 'strong'
......
bytewar / config.py
DEBUG = True
SQLALCHEMY_DATABASE_URI = 'mysql://rohit:password@localhost/flask'
SQLALCHEMY_TRACK_MODIFICATIONS = True
SECRET_KEY = 'Dont_tell_Anyone_you_key'
UPLOAD_FOLDER = 'static/img/'
RECAPTCHA_PUBLIC_KEY = 'Your key'
REMEMBER_COOKIE_DURATION = '30'
viws.py:
@user_blueprint.route('/')
def index():
post = db.session.query(Post).order_by(Post.id.desc()).all()[:5]
return render_template('index.html', post=post)
@user_blueprint.route('/about')
def about():
return render_template('about.html')
@user_blueprint.route('/contact')
@login_required
def contact():
return render_template('contact.html')
@user_blueprint.route('/user/login', methods=['POST', 'GET'])
def login():
login_form = Login_form()
return render_template('login.html', login_form=login_form)
I'd read flask documentation but not get solution.
来源:https://stackoverflow.com/questions/59783877/flask-request-url-not-found-on-the-server-error-404-not-found