Python 为什么根据我的代码,这个烧瓶不显示标准消息?
我的rest服务位于,但当我启动它时,它会给我404:Python 为什么根据我的代码,这个烧瓶不显示标准消息?,python,flask,flask-restful,Python,Flask,Flask Restful,我的rest服务位于,但当我启动它时,它会给我404: Not Found The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again. 为什么呢?我希望我的服务器显示一些状态消息,如“服务就绪” 当我按下'http://127.0.0.1:5000/parser/tengrinews'并按enter键,它将输出我在
Not Found
The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
为什么呢?我希望我的服务器显示一些状态消息,如“服务就绪”
当我按下'http://127.0.0.1:5000/parser/tengrinews'并按enter键,它将输出我在flask应用程序的函数中编码的消息:
[
"parsing this website :",
"tengrinews"
]
主要代码:
from flask import Flask
import requests
from datetime import datetime
from flask import jsonify
app = Flask(__name__)
#this is my std method i can't see
@app.route("/http://127.0.0.1:5000/", methods = ['GET'])
def main():
return jsonify('service is ready')
@app.route("/parser/<string:website>", methods = ['GET'])
def parse(website):
return jsonify("parsing this website :", website )
if __name__ == "__main__":
app.run(debug=True)
从烧瓶导入烧瓶
导入请求
从日期时间导入日期时间
从flask导入jsonify
app=烧瓶(名称)
#这是我的性病方法,我看不出来
@应用程序路线(“/http://127.0.0.1:5000/,方法=['GET'])
def main():
返回jsonify('服务就绪')
@app.route(“/parser/”,方法=['GET'])
def parse(网站):
返回jsonify(“解析此网站:”,网站)
如果名称=“\uuuuu main\uuuuuuuu”:
app.run(debug=True)
更改此行-
@app.route(“/http://127.0.0.1:5000/,方法=['GET'])
到
@app.route(“/”,methods=['GET'])
因为您必须只指定要使用的扩展URL。@app.route
装饰器为我们处理其余的部分
注意*(不要这样做。只是为了好玩)如果您希望继续使用
@app.route(“/http://127.0.0.1:5000/,methods=['GET'])
然后使用url访问端点-http://localhost:5000/http://127.0.0.1:5000/
。您将得到响应,响应为“服务准备就绪”