hostname is set from commandline now
This commit is contained in:
parent
342fa0cca3
commit
c194164e3c
10
server.py
10
server.py
@ -4,16 +4,22 @@ import random
|
||||
from app_instance import api
|
||||
from routes import *
|
||||
import wiz_game
|
||||
import argparse
|
||||
|
||||
|
||||
def main():
|
||||
print("main started")
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--port', metavar='port', default=8001, type=int, help='the port to bind to')
|
||||
parser.add_argument('--bindaddr', metavar='addr', default='127.0.0.1', help='the address to bind to')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
random.seed()
|
||||
wiz_game.the_game.start_game()
|
||||
|
||||
api.run(port=8001, address="127.0.0.1")
|
||||
#api.run(port=8001, address="192.168.42.100")
|
||||
api.run(port=args.port, address=args.bindaddr)
|
||||
exit(0)
|
||||
|
||||
|
||||
|
@ -23,7 +23,13 @@
|
||||
<![endif]-->
|
||||
<script>
|
||||
// let socket = new WebSocket("wss://cowiz.struppi.name/ws");
|
||||
let socket = new WebSocket("ws://127.0.0.1:8001/ws");
|
||||
if (window.location.hostname == '127.0.0.1') {
|
||||
ws_schema = 'ws://';
|
||||
}
|
||||
else {
|
||||
ws_schema = 'wss://';
|
||||
}
|
||||
let socket = new WebSocket(ws_schema+window.location.host+'/ws');
|
||||
window.game_socket = socket
|
||||
|
||||
socket.onopen = function(e) {
|
||||
|
@ -1,9 +1,9 @@
|
||||
from app_instance import api
|
||||
|
||||
from wiz_game import the_game
|
||||
from starlette.websockets import WebSocketDisconnect
|
||||
import asyncio
|
||||
|
||||
|
||||
# don't define here, it's defined elsewhere!
|
||||
#playing_lock = asyncio.Lock()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user