I am new to developing in general and I am trying to figure out why i keep getting {"detail":"Method Not Allowed"} here is a snipit of what i have. I am printing the http variables on the site so I know i am getting correct values. in this case strategy.id == 1 and stock.id == 1 I have checked the sql statement by manually running it in a sql viewer as
INSERT INTO stock_strategy (stock_id, strategy_id) VALUES (1, 1)
and that works as well. I am sure i am just missing a comma or some other little thing, but i cannot for the life of me find it.
<form method="post">
<select name="strategy_id">
{% for strategy in strategys %}
<option value="{{ strategy.id }}">{{ strategy.name }}</option>
{% endfor %}
</select>
<input type="text" name="stock_id" value="{{ stock.id }}" />
<input type="submit" value="Apply strategy" />
</form>
@app.post("/apply_strategy")
def apply_strategy(strategy_id: int = Form(...), stock_id: int = Form(...)):
connection = sqlite3.connect(config.db_path)
cursor = connection.cursor()
cursor.execute("""
INSERT INTO stock_strategy (stock_id, strategy_id) VALUES (?, ?)
""", (stock_id, strategy_id))
connection.commit()
return RedirectResponse(url=f"/strategy/{strategy_id}", status_code=303)
question from:
https://stackoverflow.com/questions/65905321/i-am-haveing-some-issues-with-a-post-method-i-am-getting-detailmethod-not 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…