Despite some of the comments here, I'm actually a fan of the 'homework' format. I'm not always great at hiring, but I know how to gauge the 'homework' interviews, and I've usually been right about the interviewee's abilities afterwards, WAY moreso than whiteboarding or riddles or any of the other alternatives.
That being said, I would add some constraints:
1. The 'task' shouldn't take more than 30 min to understand, and no more than 1-2 hours to do. If it takes more than that, you should make some obfuscated dummy-code endpoints that do everything you're not directly evaluating on.
2. You should let the interviewee know that it should only take 2 hours as well. If it takes more, then there was either a misunderstanding in the task, or the interviewee doesn't have the right knowledge/experience/qualifications etc.
3. You should do your homework as well, meaning you've thoroughly reviewed the code submitted and have detailed questions ready to go for the interviewee. This should also be the 'control' to make sure the interviewee really did write the code (you'll know really quickly if they didn't)
4. No other coding tasks in the interview process. You can have them review code or suggest approaches to solve problems (things that people do on the job with others)
5. The interview should be shorter than if they were asked to do whiteboarding or live coding or anything like that.
Most employers have (on paper) "trial periods" of around 3 months. A 1-2 hour coding assignment followed by 1 hour of well-crafted questions about the assignment (plus the usual interview stuff) should be enough to know whether or not you want to give the employee a chance for 3 months.
(I realize most employers don't use the evaluation period for evaluative tasks, they just have the person start and hope for the best, but if done right, it's actually a pretty good system)