Reputation: 119
I am building simple Flask web-app using Google books API. I am a beginner and maybe overthinking details, but something tells me I haven't designed this very well.
Problem I am facing:
What I find strange is that I have POST request following another POST request, just because I couldn't find a way how to send <book_id> over to the write review page. There is also problem redirecting user back since this page is @login_required but there is no GET request on it.
So my main question is: Is there a way to send <book_id> over without making the initial post request (from search result to post review page)? Maybe with javascript?
Thank you
Upvotes: 0
Views: 896
Reputation: 589
If I understood correctly, you have to send <book_id> in a GET request ?
If yes, you can do something on following lines
@api_blueprint.route('/books/<int:book_id>', methods=['GET']) #you can use the decorator yor have
def get_by_id(book_id):
print(book_id)
I had defined the blueprints for my application. But it's okay even if you don't have that. You can use simply @app.route
, or the one which you have for other POST apis.
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello, World!'
Upvotes: 1