亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

找不到燒瓶 404

找不到燒瓶 404

冉冉說 2021-09-14 16:46:55
我正在嘗試運行我的代碼,但是當我點擊鏈接時,我得到了404: Not Found. 這是我的代碼:from flask import Flask,jsonify,render_template,requestapp = Flask(__name__)if __name__ == '__main__':    app.run()tempusage = 0weightsusage = 0curencyusage = 0cost = 0userip = '1.1.1.1'@app.route('/tempreature/c2f/<int:temp>', methods=['GET'])def c2f(temp):    tempreature = temp    ftemp = (tempreature * (9/5)) + 32    tempreatures = [    {        'conversionType': u'Tempreature',        'from': u'Celcius',        'fromValue':tempreature,        'to' : u'Faherenheit',        'tovalue':ftemp    }]    global userip    userip = request.environ['REMOTE_ADDR']    global tempusage    if userip == request.environ['REMOTE_ADDR']:       tempusage  += 1    return jsonify({'tempreatures':  tempreatures})@app.route('/tempreature/f2c/<int:temp>', methods=['GET'])def f2c(temp):    tempreature = (temp -32)*(5/9)    ftemp = tempreature/10    tempreatures = [    {        'conversionType': u'Tempreature',        'from': u'Faherenheit',        'fromValue':tempreature,        'to' : u'Celcius',        'tovalue':ftemp    }]    global tempusage    global userip    userip = request.environ['REMOTE_ADDR']    if userip == request.environ['REMOTE_ADDR']:       tempusage += 1    return jsonify({'tempreatures':  tempreatures})@app.route('/weight/k2p/<int:w>', methods=['GET'])def k2p(w):    weight = w*2.205    fweight= w/10    weights = [    {        'conversionType': u'Weight',        'from': u'kg',        'fromValue':weight,        'to' : u'pounds',        'tovalue':fweight    }]    global userip    userip = request.environ['REMOTE_ADDR']    global weightsusage    if userip == request.environ['REMOTE_ADDR']:      weightsusage += 1    return jsonify({'weights': weights})我在終端得到這個:* 服務 Flask 應用程序“app”(延遲加載) * 環境:生產   警告:不要在生產環境中使用開發服務器。   改用生產 WSGI 服務器。 * 調試模式:關閉 * 在 http://127.0.0.1:5000/ 上運行(按 CTRL+C 退出)127.0.0.1 - - [11/Dec/2018 16:15:42] "GET / HTTP/1.1" 404 -
查看完整描述

2 回答

?
米脂

TA貢獻1836條經驗 獲得超3個贊

一個簡單的,但即使在編程五十年后我也會犯這樣的錯誤。您可能會發現您的 Python 運行良好,但是您沒有為您嘗試訪問的 URL 提供路由!你應該裝飾一些功能

@app.route('/')

在該功能中,您可以呈現主頁。


查看完整回答
反對 回復 2021-09-14
?
侃侃無極

TA貢獻2051條經驗 獲得超10個贊

嘗試@app.route('/')為您的功能之一添加,而路線中沒有任何其他內容。


查看完整回答
反對 回復 2021-09-14
  • 2 回答
  • 0 關注
  • 180 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號