Python Forum

Full Version: Flask Chat
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

from flask import Flask, redirect, url_for, request, render_template
import settings

app = Flask(__name__)

def receivedata():
    while True:
        data, addr = s.recvfrom(1024)
@app.route("/", methods=['POST', 'GET'])
def home():
    if request.method == 'POST':
        return render_template('home.html')
        return render_template('home.html')
Above the code If I call only receivedata function it works but when I try to work with flask and add flask code I take this error. I have no idea why. Error is " normally only one use is allowed for each socket address". How can I fix this error?
I am trying to make a chat site with socket module. I am getting mistake when I receive data on GET method. When the program go to GET method it only wait for data even if I send data(It doesn't take data).
If I remove the receiving code from GET method and put above the Flask code there isn't any problem.How can I fix it?
To start with, You need to show your code
Here is my code. I forgot to share
Please don't create duplicate threads, or link off-site for code (as you were warned about in your first post).

You should also seriously consider providing enough code for us to reproduce your error so that we can test our proposed solutions. As it stands, I don't have a home.html file and ideally you'd provide code that doesn't require it (unless it's necessary to reproduce the problem you're asking about).
I am so sorry. I didn't know the rule of this forum. So what should I do to have a answer about my problem? What should I share with you? Only home.html?
Provide a Minimal, Complete, and Verifiable example -

An example of what would make it minimal would be if you can reproduce your problem without involving Flask, then you should slim down your code.
Complete means we can run it with the details you provide (without having to manually create files).