use*_*861 2 python flask http-status-code-404
我正在使用Flask设计这个简单的网站.但我的hello方法遇到404错误.每当我点击"评价艺术家"按钮时,它都会给我错误,但home.html,hello.html和artist.html的模板都是正确的.我不知道我的代码的哪一部分是错的.有帮助吗?
@app.route("/",methods=['GET','POST'])
def login():
if request.method=="GET":
return render_template("home.html")
if request.method=="POST":
if (request.form["button"]=="login"):
return render_template("hello.html",name=request.form["name"])
@app.route("/hello",methods=['GET','POST'])
def hello():
if request.method=="GET":
if(request.form["button"]=="rate artists"):
return render_template("artist.html")
Run Code Online (Sandbox Code Playgroud)
我遇到了同样的问题.
我正在骨干和Flask之间进行一些实验性的CORS测试,作为不同网址的端点
您是在Config对象中使用SERVER_NAME还是在使用app.run时?
我把SERVER_NAME但没有指定端口,
class Config(object):
DEBUG = True
TESTING = True
STATIC_FOLDER = STATIC_FOLDER
STATIC_URL = STATIC_URL
NAVIGATION_JS = '/static/js/navigation.js'
SESSION_COOKIE_SECURE = True
REDIS_HOST_SESSION = 'localhost'
REDIS_PORT_SESSION = 6379
REDIS_DB_SESSION = 2
REDIS_HOST = 'localhost'
REDIS_PORT = 6379
REDIS_DB = 3
SERVER_NAME = 'api.jvazquez.com.ar'
Run Code Online (Sandbox Code Playgroud)
服务器名称没有端口
我也为我定义的任何路线获得了404(如果你有兴趣,我正在使用蓝图)
当我使用curl向我的烧瓶应用程序发送请求时,我得到404,这是我得到的所有蓝图的输出404
jvazquez@aldebaran:~$ curl -i http://api.jvazquez.com.ar:5000/alive/
HTTP/1.0 404 NOT FOUND
Content-Type: text/html
Content-Length: 233
Set-Cookie: session=94c2c120-34c0-4a00-b094-7b5623d438ff; Domain=.api.jvazquez.com.ar; HttpOnly; Path=/
Server: Werkzeug/0.9.4 Python/2.7.3
Date: Wed, 25 Dec 2013 11:21:16 GMT
Run Code Online (Sandbox Code Playgroud)
因此,请检查是否已定义配置变量SERVER_NAME并且它具有端口
| 归档时间: |
|
| 查看次数: |
7430 次 |
| 最近记录: |