Add csrf middleware
Reformat code