Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

I need assist on python|flask, passing data through url

GET /users/items?returned=false <---- this the url.
Now what i need to do is to create an endpoint that will check on my database for the return status of an item if it is false then all of the items will be returned. I can do everything from checking the db for the return status of an item. What i dont know is how to wtite the URL for the endpont such that when a user vists that endpoint , he or she gets the items whose return status is false. I hope this gives the picture of what i cant implement

since i cantot do this as it wont work
@app.route("/users/items?eturned=false", methods = ['GET'])
def items_unreturned()
.........
you code has an issue '@app.route("/users/items?eturned=false", methods = ['GET'])' it should be'returned' like above.

which framework do you use django, flask or tornado?
(May 9, 2018 02:07 PM).kr. Wrote:  you code has an issue '@app.route("/users/items?eturned=false", methods = ['GET'])' it should be'returned' like above.

which framework do you use django, flask or tornado?

He's using Flask.




Have you tried passing it through the url as a variable. app.route('users/products?returned=<isReturned>')

Not a false wizard, but hopefully this works.
Skype messages are NOT valid evidence, and here's why.
I typically write my urls like:

@app.route('/items/<int:ID>/<name>')
@app.route('/items/<int:ID>/<name>/<category>')
def listItem(ID,name,category=None):
   dostuff()
   return "I did stuff."
I am using flask as @Scapegoat has said. What i dont know is basically how to get parrameters passed via url, but i  think from these suggestions its not much different from passing parameters the body(payload), so let me give it a shot.Thanks guys 🙂 🙂


Now guys one more thing, this needs to be implemented using the returned?=false wizard. what i dont get is the standard or the appropriate way to implement it as i said havin an endpoint such as: "/users/items?returned=false" hard coded like that wont work(i stand corrected though), so the url should i guess allow the user to enter the false value so that the system can querry for the items yet to be returned.The question mark appended at the end of returned must be meaning something right?


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Bass_ReevesAug 20, 2023 01:44 AM 9 631 Aug 20, 2023 01:44 AM
Last Post: Lucky4L
[Python] by ivankirevichMar 4, 2023 11:22 AM 6 247 Mar 4, 2023 11:22 AM
Last Post: ivankirevich
[Python] by еlixirAug 7, 2022 11:43 AM 3 202 Aug 7, 2022 11:43 AM
Last Post: Pat13nt_Zer0