Check if device is mobile in Flask Check if device is mobile in Flask flask flask

Check if device is mobile in Flask


I solved the problem using Flask-Mobility. It allows to detect if the device is mobile

from flask_mobility import Mobility...app = Flask(__name__)Mobility(app)...{% for doc in docs %}    <tr>        <td>{{doc.phone if doc.phone}}</td>        <td>{{doc.email if doc.email}}</td>        <td>            {% if request.MOBILE %}                <a href="/cv/{{doc.name}}" target="_blank"><i class="material-icons">open</i> Ouvrir</a>            {% else %}                <div class="modal" id="modal{{loop.index}}">                    <iframe src="/cv/{{doc.name}}" scrolling="no" width="100%" height="100%"></iframe>                </div>                <a href="#modal{{loop.index}}" class="modal-trigger"><i class="material-icons">open</i> Ouvrir</a>            {% endif %}       </td>    </tr>{% endfor %}