python - 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?
解决方案
如果有人遇到类似的问题,我发现一个剩余的 flask.exe 进程仍在运行,该进程未正确终止,因此仍在提供路由本身。因此,解决方案是手动终止该进程。打算把这个打开,也许有人会遇到同样的问题
推荐阅读
- python - 无法将 float32 序列化为 JSON
- flutter - 多次重建脚手架不好吗?
- c# - 如何修改此正则表达式以使其仅匹配目录并排除文件?
- c# - 使用 ngx-translate 翻译错误端服务器
- android - 我得到了我用来制作应用程序的三星 (7.1.1) 设备。当我尝试将应用程序直接运行到设备时,它会显示一条错误消息
- c# - 有没有一种直接的方法可以将 WPF .NET Framework 应用程序转换为 UWP .NET Core?
- php - 如何在php中检查日期范围列表中的日期范围
- python - 是否可以设置 Pika SelectConnection 轮询间隔?
- php - 如何使用 Silverstripe 控制器默认返回 JSON?
- events - 此触发什么事件以及如何取消它?