We have a working multi page python flask web MVC application using bootstrap. We are looking to create app for smartphones and we decided ionic would be the better framework (along angular) since we want app for both Android and iOS.
However since out base application is multi page versus single page angular, most of out code isn't reusable as it.
I have multiple endpoints in my flask app.py file of format:
@app.route('/path',methods=['GET']) def path():
I have another file for model and jinja2 *.html view files.
To communicate with mobile app I have to solutions:
- Send requests to currents endpoints maintaining same paths than web application, but in the case they are detected as mobile request, JSON is returned in place of HTML
- Creating new endpoints for mobile requests. However this would imply a lot of duplicated code unless I create another "level 2" model used by both web and app requests.
In the case of authentication I have also though in two solutions:
- Same authentication than web browser: cookies (I don't know currently how it would by implemented in angular)
- Use JWT tokens as authentication for mobile requests.
What would be good practices here?