Skip to content

Creating a simple health app #315

Answered by Marcel-Jan
Marcel-Jan asked this question in Q&A
Discussion options

You must be logged in to vote

Okay I think I've got it. I actually managed to create a post method to save a row with data in the sqlite database.

So what did I do to get it working?
The home function is largely unchanged (except for the added BMI input).

I've added a post function and learned that you need to put the weight (and bmi) in as arguments. The route is "/" because we're not going anywhere. We're only going to insert data.

@app.route("/", methods=['post'])
def post(weight:float, bmi:float):

You can add a return to this function that shows data has actually been passed through:
return f"Entered into the database: weight={weight}, bmi={bmi}"

The insert statement works like this:
healthdata.insert(HealthData(…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Marcel-Jan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant