virtualenv venv
source ./venv/bin/activate
pip install -r requirements.txt
export FLASK_APP=codegame.py
flask db init
flask db migrate
flask db upgrade
flask run
and Running on http://127.0.0.1:5000/
cd gameserver
virtualenv venv
source ./venv/bin/activate
pip install -r requirements.txt
python server_test.py
and Running on http://127.0.0.1:6005/ (communicate with webserver)python games/easy/codes/pingpong/gamemain.py
and Running on http://127.0.0.1:8000/ (communicate with players)
- 程式碼由 app/games/routes.py 的 game_view function中,當 commit_form.validate_on_submit(),就build a websocket client: ws = create_connection("ws://localhost:6005")
- gameserver這邊由 server_test.py build websocket server接收 玩家程式碼
3. server_test.py 等待兩位玩家都上傳程式碼4. fork 3 processes to execute 玩家程式碼 和 遊戲程式
- 由 url:
http://localhost:5000/games
輸入要進入的聊天室 - Webserver 透過 app/main/events.py 來接收 socket 訊息(聊天室和
遊戲物件位置) gi