This commit is contained in:
nopy 2024-07-11 17:59:17 +08:00
commit eb068333c6
4 changed files with 10 additions and 8 deletions

View File

@ -21,7 +21,7 @@ export default function Test({ ip = "", port = "22", password = "123456", user =
if (terminal !== null) { if (terminal !== null) {
terminal.open(terminalObj.current); terminal.open(terminalObj.current);
const newSocket = io("ws:///"); const newSocket = io("ws://" + window.location.host);
setSocket(newSocket); setSocket(newSocket);
terminal.onData((data) => { terminal.onData((data) => {

View File

@ -29,7 +29,7 @@ services:
ports: ports:
- '8000:8000' - '8000:8000'
- '8765:8765' - '8765:8765'
command: gunicorn -w 3 -t 60 -b 0.0.0.0:8000 app:app command: python app.py
code-server: code-server:
build: ./docker/code-server build: ./docker/code-server

View File

@ -39,4 +39,4 @@ COPY --from=build-frontend /usr/src/app/build/ /home/flask/public/
EXPOSE 8000 22 8765 EXPOSE 8000 22 8765
USER root USER root
CMD ["gunicorn", "-w", "3", "-t", "60", "-b", "0.0.0.0:8000", "app:app"] CMD ["python", "app.py"]

View File

@ -11,19 +11,21 @@ from student_func import *
from flask import Flask, render_template, request, jsonify, send_from_directory, session from flask import Flask, render_template, request, jsonify, send_from_directory, session
from flask_cors import CORS from flask_cors import CORS
from flask_socketio import SocketIO, emit, disconnect from flask_socketio import SocketIO, emit, disconnect
from engineio.payload import Payload
Payload.max_decode_packets = 500
import logging import logging
import os import os
print(os.getcwd())
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
app = Flask(__name__, static_folder="public") app = Flask(__name__, static_folder="public")
CORS(app) CORS(app)
cors = CORS(app, resource={ cors = CORS(app, resources={
r"/*":{ r"/*":{
"origins":"*" "origins":"*"
} }
}) })
app.config['SECRET_KEY'] = '350625' app.config['SECRET_KEY'] = '350625'
socketio = SocketIO(app, cors_allowed_origins="*") socketio = SocketIO(app, cors_allowed_origins="*", ping_timeout=1000, ping_interval=0)
clients = {} clients = {}
@ -107,7 +109,7 @@ def register():
# def get_lesson(): # 获取课程 # def get_lesson(): # 获取课程
# student_id = session.get('id') # student_id = session.get('id')
# student_lesson = get_lesson_func(student_id) # student_lesson = get_lesson_func(student_id)
# print(student_lesson) # print(student_lesson)
# return jsonify({"student_lesson": student_lesson}) # return jsonify({"student_lesson": student_lesson})
@ -450,6 +452,6 @@ def handle_disconnect():
if __name__ == '__main__': if __name__ == '__main__':
socketio.run(app, host='0.0.0.0', port=5000 ,allow_unsafe_werkzeug=True, debug=True) socketio.run(app, host='0.0.0.0', port=8000 ,allow_unsafe_werkzeug=True, debug=False)