python flask input multiple value, how can we multiply or doing the calculation from the value we get from URL(how can i correct)

Viewed 38
# import main Flask class and request object
from flask import Flask, request

# create the Flask app
app = Flask(__name__)



@app.route('/data')
def query_example():
    # if key doesn't exist, returns None
    name = request.args.get('name')

# if key doesn't exist, returns a 400, bad request error
CustomerID = request.args['CustomerID']

# if key doesn't exist, returns None
website = request.args.get('website')

return '''
          <h1>The name is: {}</h1>
          <h1>The CustomerID is: {}</h1>
          <h1>The website value is: {}'''.format(name, CustomerID, website)


if __name__ == '__main__':
    # run app in debug mode on port 5000
    app.run(debug=True, port=5000)

I like to get the data from URL input and using flask to deal with the data, how can I improve my code, thanks.

now I do could get the value and put them on website, but couldn't apply the value, showing their datatype or chaning value datatype.

ex: http://127.0.0.1:5000/index/data?name=james&id=123

output:

  • name=james
  • id=123
  • new id= 246 (can capture url data for calculation)
  • the data type is = str() --> float()

code pic

what i reach pic(missing data calculation and showing data type)

0 Answers
Related