相关疑难解决方法(0)

PUT和DELETE应该用在表格中吗?

假设我的Web应用程序在服务器端完全支持PUT和DELETE,我应该使用它们吗?

基本上我的问题是有多少浏览器支持这个:

<form method="PUT">
Run Code Online (Sandbox Code Playgroud)

要么

<form method="DELETE">
Run Code Online (Sandbox Code Playgroud)

除了兼容REST之外,使用这两种HTTP方法有什么好处吗?(假设替换这两种方法是常用的POST)

html rest http cross-browser

70
推荐指数
4
解决办法
7万
查看次数

Flask - POST错误405方法不允许

我刚刚开始学习Flask,我正在尝试创建一个允许POST方法的表单.这是我的方法:

@app.route('/template', methods=['GET', 'POST'])
def template():
    if request.method == 'POST':
        return("Hello")
    return render_template('index.html')
Run Code Online (Sandbox Code Playgroud)

我的index.html:

<html>

<head>
  <title> Title </title>
</head>

<body>
  Enter Python to execute:
  <form action="/" method="post">
    <input type="text" name="expression" />
    <input type="submit" value="Execute" />
  </form>
</body>

</html>
Run Code Online (Sandbox Code Playgroud)

加载表单(在收到GET时呈现它)工作正常.但是,当我单击提交按钮时,我收到POST 405错误方法不允许.为什么不显示你好?

python post http flask

56
推荐指数
3
解决办法
8万
查看次数

烧瓶中方法不允许错误

尝试提交请求时出现此错误。

Method Not Allowed

The method is not allowed for the requested URL.
Run Code Online (Sandbox Code Playgroud)

这是我的烧瓶代码。

@app.route("/")
def hello():
  return render_template("index.html")

@app.route("/", methods=['POST','GET'])
def get_form():
  query = request.form["search"]
  print query
Run Code Online (Sandbox Code Playgroud)

还有我的index.html

<body>

<div id="wrap">
  <form action="/" autocomplete="on" method="POST">
    <input id="search" name="search" type="text" placeholder="How are you feeling?">
     <input id="search_submit" value="Send" type="submit">
  </form>
</div>

  <script src="js/index.js"></script>

</body>
Run Code Online (Sandbox Code Playgroud)

编辑..我完整的烧瓶代码:

from flask import  Flask,request,session,redirect,render_template,url_for
import flask
print flask.__version__
app = Flask(__name__)

@app.route("/")
def entry():
    return render_template("index.html")

@app.route("/data", methods=['POST'])
def entry_post():
    query = request.form["search"]
    print query
    return …
Run Code Online (Sandbox Code Playgroud)

html python flask

5
推荐指数
1
解决办法
8050
查看次数

标签 统计

flask ×2

html ×2

http ×2

python ×2

cross-browser ×1

post ×1

rest ×1