首页 > 解决方案 > Flask routes not updating

问题描述

I'm trying to bootstrap a basic flask setup but after managing to setup the db connection and running the server, the routes are not being updated but seem to be cached to the original route I added in the very beginning (Which now doesn't even exist).

Below is the relevant code.

launch.py (python file pointed at by FLASK_APP)

from app import app,db
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand


#Model Creation

migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)

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

app.py

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from config import Config

app = Flask(__name__)
app.config.from_object(Config)
db = SQLAlchemy(app)

@app.route("/", methods=['GET'])
def home():
    return "Hello World!!"


@app.route("/test", methods=['GET'])
def test():
    return "Test"

Note that with or without the given routes the only route that works is the / one and returns "Hello World!" which was the original string, but now the routes aren't being updated.

Could anyone please shed some light on this?

标签: pythonflasksqlalchemyroutesflask-sqlalchemy

解决方案


如果有人遇到类似的问题,我发现一个剩余的 flask.exe 进程仍在运行,该进程未正确终止,因此仍在提供路由本身。因此,解决方案是手动终止该进程。打算把这个打开,也许有人会遇到同样的问题


推荐阅读