Ask coding questions

← Back to all posts
/posts route not working - Flask
isaiah08 (63)

Login using the credentials test as username and pass as password. Then go to the /post route. Post something, and it should redirect you to the /posts route - BUT IT DOESN'T HAVE YOUR POST! Why?

Comments
hotnewtop
JBloves27 (1729)

It should have something with the db or json. Maybe look through your code? Tell me if you need any other help!

isaiah08 (63)

I looked through my code. It definetely has something to do with the db. I think the problem is line 103:

db['new'].insert(0, [title, session.get('login'), post, 0])

This line doesn't actually add anything to the db. Why???
@JBYT27

JBloves27 (1729)

hmmmm... could it be the syntax? Does that code usually work by itself? @isaiah08

isaiah08 (63)

Yes, it does! It can't be the syntax, as i'm not getting an error. @JBYT27

JBloves27 (1729)

hmmm... maybe it could be the 0? Curious, why do you have to enter the 0? @isaiah08

isaiah08 (63)

Umm.. do you know python? The insert function on a list needs the position you want to insert it in. @JBYT27