Answer the question
In order to leave comments, you need to log in
404 error while processing flask get request?
Hello. There is a 404 error when trying to make a get request to the server on flask.
The request looks like this: 34.71.113.109/?MERCHANT_ID=213123&AMOUNT=2313&inti...
And here is the server code:
from flask import Flask
app = Flask(__name__)
@app.route("/?MERCHANT_ID=<shop_id>&AMOUNT=<price>&intid=<op_id>&MERCHANT_ORDER_ID=<chat_id>", methods=['GET'])
def hello(shop_id,price,op_id,chat_id):
return f"{chat_id}"
app.run(host = "0.0.0.0", port = 80)
Answer the question
In order to leave comments, you need to log in
In route rules, you can only set address parameters, that is, if you write
@app.route(rule='/<foo>/<bar>', methods=['GET'])
def index(foo, bar):
....
foo
and bar
are address parameters, that is, example.com/asda/dasda
. If you need to get address arguments, for example example.com/?foo=asda
, then you need to use request.args
, that is:from flask import request
@app.route(rule='/', methods=['GET'])
def index():
if request.args.get('foo'):
return f'{request.args["foo"]}'
....
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question