Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!