title: How do I get rid of this error 405 ? (Flask/Py)
body: <p>I want to make a chat application with Flask and socket.io, but I keep getting an error 405 whenever I click on &quot;send&quot;. I've been trying to make this work, but it just won't (just a basic thing with a username and a message). Here is what the error says:</p>
  <blockquote>
  <p>&quot;Method Not Allowed
  The method is not allowed for the requested URL.&quot;</p>
  </blockquote>
  <p>I don't really know what's wrong. When I check my cmd, I see:</p>
  <blockquote>
  <p>POST / HTTP/1.1&quot; 405 362 0.001000
  127.0.0.1 - - [28/May/2021 16:44:29] &quot;GET /socket.io/?EIO=3&amp;transport=websocket&amp;sid=7392cec39d5841bcaa7d7c8faaa1b6fb
  HTTP/1.1&quot; 200 0 3.134387</p>
  </blockquote>
  <p>main.py:</p>
  <pre><code>from flask import Flask, render_template #Importation du modèle flask et de render_template
  from flask_socketio import SocketIO #Importation du modèle socketio
  
  app = Flask(__name__)
  app.config['SECRET_KEY'] =b'\xba!\xe3];\xce\xe6V}\x1d\xee\xda\x03\x8b\xbfS\xb9\x0fE\x8f\x15\x98O\x92' #Clé secrète afin de garder la partie client sécurisée
  socketio = SocketIO(app)
  
  
  @app.route('/')
  def index(): #Définition de la fonction index
      return render_template('index.html') #Affichage de la page index.html
  
  
  def messageReceived(methods=['GET', 'POST']): #Définition de la fonction message reçu
      print('Message reçu')
  
  
  @socketio.on('my event') 
  def handle_my_custom_event(json, methods=['GET', 'POST']): #Définition de la fonction message envoyé
      print('Mon événement a été reçu: ' + str(json))
      socketio.emit('Ma réponse', json, callback=messageReceived) #Émission du message
  
  
  if __name__ == '__main__':      #Boucle permettant à l'application web de continuer de fonctionner à l'infinie
      socketio.run(app, debug=True)
  </code></pre>
  <p>index.html:</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang=&quot;fr&quot;&gt;
      &lt;head&gt;
          &lt;meta charset=&quot;utf-8&quot;&gt;
          &lt;title&gt;Chat Flask&lt;/title&gt;
          &lt;link rel=&quot;stylesheet&quot; href=&quot;{{url_for('static', filename='index.css')}}&quot;&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;p id=&quot;para1&quot; style='color: #9cd374;font-size: 30px;'&gt;Pas de message...&lt;/p&gt;
          &lt;div class=&quot;message_holder&quot;&gt;&lt;/div&gt;
          &lt;form action=&quot;&quot; method=&quot;POST&quot;&gt;
              &lt;div class=&quot;inputs&quot;&gt;
              &lt;input type=&quot;text&quot; id=&quot;username&quot; placeholder=&quot;Nom d'utilisateur&quot;/&gt;
              &lt;input type=&quot;text&quot; id=&quot;message&quot; placeholder=&quot;Message&quot;/&gt;
              &lt;input type=&quot;image&quot; id=&quot;send&quot; src=&quot;static/send.png&quot;/&gt; 
                  &lt;!-- Utilisation direct du &lt;style&gt; car le css ne fonctionne pas pour les entrées --&gt;
                  &lt;style&gt;
        input[type=&quot;email&quot;] {
          text-align: center;
        }
        input[type=&quot;text&quot;] {
          text-align: right;
        }
        input[type=&quot;tel&quot;] {
          text-align: left;
        }
        body {
          text-align: center;
        }
        label {
          display: block;
          margin-bottom: 30px;
        }
      &lt;/style&gt;
              &lt;/div&gt;
          &lt;/form&gt;
          &lt;!-- Script JS nécessaire pour utiliser socketIO --&gt;
          &lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js&quot;&gt;&lt;/script&gt; 
          &lt;script type=&quot;text/javascript&quot; src=&quot;//cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.6/socket.io.min.js&quot;&gt;&lt;/script&gt;
          &lt;script type=&quot;text/javascript&quot;&gt;
              var socket;
              $(document).ready(function(){
                  socket = io.connect('http://' + document.domain + ':' + location.port + '/chat');
                  socket.on('connect', function() {
                      socket.emit('joined', {});
                  });
                  socket.on('status', function(data) {
                      $('#chat').val($('#chat').val() + '&lt;' + data.msg + '&gt;\n');
                      $('#chat').scrollTop($('#chat')[0].scrollHeight);
                  });
                  socket.on('message', function(data) {
                      $('#chat').val($('#chat').val() + data.msg + '\n');
                      $('#chat').scrollTop($('#chat')[0].scrollHeight);
                  });
                  $('#text').keypress(function(e) {
                      var code = e.keyCode || e.which;
                      if (code == 13) {
                          text = $('#text').val();
                          $('#text').val('');
                          socket.emit('text', {msg: text});
                      }
                  });
              });
        &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>