0

I'm trying to connect to different databased based on the URL parameter using flask

In defined the route as

@app.route('/data_service/file/<string:db>/', methods=['GET','DELETE','POST','PUT'])
def file():

However, flask complains that

TypeError: file() got an unexpected keyword argument 'db'

Imho this should work according to description, e.g. https://pythonprogramming.net/flask-url-converters-tutorial/

CAFEBABE
  • 3,983
  • 1
  • 19
  • 38
  • Does this answer your question? [Can Flask have optional URL parameters?](https://stackoverflow.com/questions/14032066/can-flask-have-optional-url-parameters) – Derte Trdelnik Oct 30 '19 at 18:26

1 Answers1

0

I found the mistake

The parameter should have occurred in the function in that case the code should have been

@app.route('/data_service/file/<string:db>/', methods=['GET','DELETE','POST','PUT'])
def file():
CAFEBABE
  • 3,983
  • 1
  • 19
  • 38
  • wasted now 2 hours and found the answer on my one once it was posted :-( still might be helpful for somebody else – CAFEBABE Oct 30 '19 at 18:25