views:

41

answers:

3

EDIT:Question Updated. Thanks Slott.

I have a TCP Server in Python.

It is a server with asynchronous behaviour. .

The message format is Binary Data.

Currently I have a python client that interacts with the code.

What I want to be able to do eventually implement a Web based Front End to this client.

I just wanted to know , what should be correct design for such an application.

A: 

For Web-based, talk HTTP. Use JSON or XML as data formats.

Be standards-compliant and make use of the vast number of libraries out there. Don't reinvent the wheel. This way you have less headaches in the long run.

knitti
A: 

Start with any WSGI-based web server. werkzeug is a choice.

The Asynchronous TCP/IP is a seriously complicated problem. HTTP is synchronous. So using the synchronous web server presenting some asynchronous data is always a problem. Always.

The best you can do is to buffer things and have two processes in your web application.

  1. TCP/IP process that collects data from the remove server and buffers it in a file (or files) somewhere.

  2. WSGI web process which handles GET/POST processing.

    • GET requests will fetch some or all of the buffer and display it.

    • POST requests will send a message to the TCP/IP server.

S.Lott
Exactly thats what I am thinking, using TCP/IP and returning the results for display but there are also some asynchronous elements to this application. I was wondering How would I implement this on the client side, as in Javascript<->python interactions
anijhaw
something like a python server calling JavaScript Asynchronously.
anijhaw
@anijhaw: **Update** your question to contain **all** the relevant information. Your question says "simple server with a request-reply behavior". Your comment says "some asynchronous elements". Please pick one of the two and stick to it. Please don't randomly add new requirements. Please don't add requirements in a comment. Please **update** your question to be complete and consistent.
S.Lott
A: 

if you need to maintain a connection to a backend server across multiple HTTP requests, Twisted's HTTP server is an ideal choice, since it's built to manage multiple connections easily.

Allen