Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

128
Vistas
Fetch Request with Multiple Parameters | Flask

How do I send a fetch request with two parameters to my flask server? I have the flask working but I am not sure about the javascript part.

Javascript Code:

    var symbol = document.getElementById("stock-symbol").value;
    var quantity = document.getElementById("quantity").value;

    fetch(`/game/market-simulator/make-sell-request/${symbol}${quantity}`)

Python Code:

@app.route("/game/market-simulator/make-sell-request/<symbol>/<quantity>", methods=["GET", "POST"])
def sell_stocks(symbol, quantity):
    if request.method == "GET":
        try:
            symbol = str(symbol)
            quantity = int(quantity)

        except ValueError:
            return render_template("sell-page.html")

        return symbol, quantity
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Using params like this:

javascript:

fetch(`/game/market-simulator/make-sell-request/?symbol=${symbol}&quantity=${quantity}`)

python:

from flask.globals import request
...
@app.route("/game/market-simulator/make-sell-request")
def sell_stocks():
    symbol = request.args.get('symbol')
    quantity= request.args.get('quantity')
    return symbol, quantity

attention, params default type is string.

If you want to continue to use this flask routings,you can do this in JavaScript

fetch(`/game/market-simulator/make-sell-request/${symbol}/${quantity}`)

Pay attention to the sequence between symbol and quantity

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda