This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from flask import Flask, request | |
from flask_sse import sse | |
app = Flask(__name__) | |
app.config["REDIS_URL"] = "redis://localhost:6379" | |
app.register_blueprint(sse, url_prefix="/stream") | |
@app.route("/chat", methods=["POST"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function appendChat(chat) { ... } | |
function sendChat() { | |
event.preventDefault(); | |
const chatForm = document.getElementById("chat-form"); | |
const chatMessage = chatForm.elements.message.value; | |
const xhr = new XMLHttpRequest(); | |
xhr.open('POST', 'chat'); |