Re: Simple webserver

2023-10-21 Thread Janis Papanagnou via Python-list
On 20.10.2023 23:05, Paul Rubin wrote:
> Janis Papanagnou  writes:
>> I found a Python sample[*] but I am neither familiar with
>> Python nor with the 'simple_websocket_server' package that
>> is used in that sample code. But the code looks so simple
>> that I'm considering to learn and use Python for the task.
> 
> I've generally used ThreadingServer(SocketServer) for this purpose
> and I think threads are less confusing than async, and performance is
> fine if the concurrency level is not too high.  But, trying to write a
> web server in Python if you don't know Python doesn't seem like a great
> idea, except as a learning project.

I have a couple decades experience with about a dozen programming
languages (not counting assemblers). Asynchronous processing, IPC,
multi-processing, client/server architectures, multi-threading,
semaphores, etc. etc. are concepts that are not new to me.

I'm not, literally, intending to write a web-server. It's a JS
application that is running in (browser based) clients, and the
server is just centrally coordinating the client applications.

My expectation would be that any sophistically designed socket/
web-socket library would not impose any risk. And the intended
server by itself has only very limited requirements; listening to
incoming request, storing some client information, broadcasting
to the attached clients. Basically just (informally written):

  init server
  forever:
wait for request(s) -> queue
handle requests from queue (sequentially):
  store specific information from new registered clients
  broadcast some information to all registered clients

It seems to me that multi-threading or async I/O aren't necessary.

I'd like to ask; where do you see the specific risks with Python
(as language per se) and it's (web-socket-)libraries here?

If the web-socket IPC is well supported the algorithmic parts in
Python seem trivial to learn and implement. - Or am I missing
something?

(A brief search gave me the impression that for JS communication
web-sockets would be the method to use. Otherwise I'd just use
basic Unix domain sockets for the purpose and write it, say, in
C or C++ that I already know. But I don't know whether (or how)
plain sockets are used from JS running in a browser. Here I'm
lacking experience. And that lead me to have a look at Python,
since the web-sockets/server examples that I found looked simple.)

Janis

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple webserver

2023-10-20 Thread Janis Papanagnou via Python-list
On 19.10.2023 01:23, Chris Angelico wrote:
> 
> Broadly speaking, your ideas are great. Any programming language CAN
> be used for the server (and I've used several, not just Python).

Out of curiosity; what where these languages? - If there's one I
already know I might save some time implementing the server. :-)

Janis

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Simple webserver

2023-10-18 Thread Janis Papanagnou via Python-list
On 19.10.2023 01:23, Chris Angelico wrote:
> [snip]
> 
> Hope that's enough to get you started! I'd be delighted to help
> further if you run into difficulties.

Thanks for your quick reply, Chris! This is already great information!
I'll dive into your resources soon, and I also appreciate your offer
and will probably come back soon with a question... - Thanks again!

Janis

-- 
https://mail.python.org/mailman/listinfo/python-list


Simple webserver

2023-10-18 Thread Janis Papanagnou via Python-list
I am pondering about writing a client/server software with
websockets as communication protocol. The clients will run
in browser as Javascript programs and the server may be in
any (any sensible) programming language running standalone
to be connected remotely by the browser-based JS clients.

I found a Python sample[*] but I am neither familiar with
Python nor with the 'simple_websocket_server' package that
is used in that sample code. But the code looks so simple
that I'm considering to learn and use Python for the task.

The requirements I have are quite simple; I want to get the
client "address"/identifier from an incoming message, store
it in a list, and send responses to all active clients for
which addresses have been stored.

Can anyone tell me whether a simple extension of that "echo
incoming message" sample[*] would be easily possible with
Python and with that 'simple_websocket_server' package used?

Thanks for any hints (or search keywords, or code samples)!

Janis

[*] https://pypi.org/project/simple-websocket-server/
-- 
https://mail.python.org/mailman/listinfo/python-list