Reworked setup.py, now you can run cmd_chat directly. Reworked sanic http webserver to make it work. Update readme, etc...

This commit is contained in:
mirai
2023-11-27 14:30:01 +03:00
parent c5fa982f65
commit 316a0e3e1e
7 changed files with 76 additions and 67 deletions
+9 -9
View File
@@ -1,19 +1,15 @@
import asyncio
import argparse
from cmd_chat.server.server import app
from cmd_chat.server.server import run_server
from cmd_chat.client.client import Client
async def run_server(
def run_http_server(
ip: str,
port: int
) -> None:
app.run(
host=ip,
port=port,
dev=False
)
run_server(ip, port, False)
async def run_client(
@@ -53,12 +49,16 @@ async def run() -> None:
)
args = parser.parse_args()
if args.command == 'serve':
await run_server(args.ip_address, int(args.port))
run_http_server(args.ip_address, int(args.port))
elif args.command == 'connect':
if not args.username:
parser.error("Username is required for 'connect' command")
await run_client(args.username, args.ip_address, int(args.port))
def main():
asyncio.run(run())
if __name__ == '__main__':
asyncio.run(run())
main()