Switch to Flask for API