python 中flask 问题
from flask import Flask,request,jsonifyapp = Flask(__name__)
def count_char(a,b):
return a+b;
@app.route('/test',methods=["get"])
def get_data():
name=request.args.get("name")
age=request.args.get("age")
res=count_char(name.age)
return res
if __name__ == '__main__':
app.run(host="127.0.0.1",port=7722,debug=True)
运行结果
FLASK_APP = app.py
FLASK_ENV = development
FLASK_DEBUG = 0
In folder F:/nlpprogram/flask-project
D:flask-projectScriptspython.exe -m flask run
- Serving Flask app "app.py"
- Environment: development
- Debug mode: off
- Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
我明明把端口改成7722,,怎么还是5000?
回答:
大概率是因为你用了 pycharm 之类的 IDE,默认是 Flask 模式(即 flash run
)。
要么你在启动的时候指定参数(flash run -p 7722
);要么切换到 python 模式下运行。
跟你同样的问题:https://segmentfault.com/q/10...
以上是 python 中flask 问题 的全部内容, 来源链接: utcz.com/a/158654.html