Re: Simple webserver
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
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
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
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
Re: Quickie - Regexp for a string not at the beginning of the line
Am 26.10.2012 06:45, schrieb Rivka Miller: Thanks everyone, esp this gentleman. Who is "this"? The solution that worked best for me is just to use a DOT before the string as the one at the beginning of the line did not have any char before it. Which was what I suggested, and where you rudely answered... no one has really helped yet. And obviously... I am a satisfied custormer. ...your perception about yourself and about the role of us Usenet posters seems also not be very sane. Good luck. -- http://mail.python.org/mailman/listinfo/python-list
Re: Quickie - Regexp for a string not at the beginning of the line
On 25.10.2012 22:53, Rivka Miller wrote: > Hello Programmers, > > I am looking for a regexp for a string not at the beginning of the > line. > > For example, I want to find $hello$ that does not occur at the > beginning of the string, ie all $hello$ that exclude ^$hello$. .hello The dot represents any character. But for specific strings that needs adjustments (e.g. looking for hh not at the beginning of a line would require something like ^[^h]+hh - ah, well, you wrote something similar below). Janis > > In addition, if you have a more difficult problem along the same > lines, I would appreciate it. For a single character, eg < not at the > beginning of the line, it is easier, ie > > ^[^<]+< > > but I cant use the same method for more than one character string as > permutation is present and probably for more than one occurrence, > greedy or non-greedy version of [^<]+ would pick first or last but not > the middle ones, unless I break the line as I go and use the non- > greedy version of +. I do have the non-greedy version available, but > what if I didnt? > > If you cannot solve the problem completely, just give me a quick > solution with the first non beginning of the line and I will go from > there as I need it in a hurry. > > Thanks > > -- http://mail.python.org/mailman/listinfo/python-list