Spaces:
Runtime error
Runtime error
namespace
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from flask import Flask, request, render_template, send_file, jsonify, send_from_directory
|
| 2 |
from flask_socketio import SocketIO, join_room, leave_room, close_room, rooms, disconnect
|
| 3 |
from flask_cors import CORS
|
| 4 |
from flask_limiter import Limiter
|
|
@@ -59,7 +59,7 @@ def update_queue_status(message):
|
|
| 59 |
|
| 60 |
def process_task(task):
|
| 61 |
try:
|
| 62 |
-
client_id =
|
| 63 |
task.is_processing = True
|
| 64 |
# ファイルデータをPIL Imageに変換
|
| 65 |
image = Image.open(io.BytesIO(task.file_data))
|
|
@@ -118,6 +118,7 @@ connected_clients = 0
|
|
| 118 |
tasks_per_client = {}
|
| 119 |
@socketio.on('connect', namespace='/')
|
| 120 |
def handle_connect(auth):
|
|
|
|
| 121 |
client_id = request.sid # クライアントIDを取得
|
| 122 |
join_room(client_id) # クライアントを自身のルームに入れる
|
| 123 |
global connected_clients
|
|
@@ -148,7 +149,7 @@ def submit_task():
|
|
| 148 |
|
| 149 |
# クライアントIPアドレスを取得
|
| 150 |
client_ip = get_remote_address()
|
| 151 |
-
client_id =
|
| 152 |
|
| 153 |
# 同一IPからの同時タスク数を制限
|
| 154 |
if tasks_per_client.get(client_ip, 0) >= 2:
|
|
|
|
| 1 |
+
from flask import Flask, request, render_template, send_file, jsonify, send_from_directory, session
|
| 2 |
from flask_socketio import SocketIO, join_room, leave_room, close_room, rooms, disconnect
|
| 3 |
from flask_cors import CORS
|
| 4 |
from flask_limiter import Limiter
|
|
|
|
| 59 |
|
| 60 |
def process_task(task):
|
| 61 |
try:
|
| 62 |
+
client_id = session.get("sid")
|
| 63 |
task.is_processing = True
|
| 64 |
# ファイルデータをPIL Imageに変換
|
| 65 |
image = Image.open(io.BytesIO(task.file_data))
|
|
|
|
| 118 |
tasks_per_client = {}
|
| 119 |
@socketio.on('connect', namespace='/')
|
| 120 |
def handle_connect(auth):
|
| 121 |
+
session["sid"] = request.sid
|
| 122 |
client_id = request.sid # クライアントIDを取得
|
| 123 |
join_room(client_id) # クライアントを自身のルームに入れる
|
| 124 |
global connected_clients
|
|
|
|
| 149 |
|
| 150 |
# クライアントIPアドレスを取得
|
| 151 |
client_ip = get_remote_address()
|
| 152 |
+
client_id = session.get("sid")
|
| 153 |
|
| 154 |
# 同一IPからの同時タスク数を制限
|
| 155 |
if tasks_per_client.get(client_ip, 0) >= 2:
|