This Python script is a simple Flask application designed to act as a server for handling client connections and messages. It provides functionality for user authentication, listing connected clients, sending messages to specific clients, and logging server activities.
- Flask
- Threading
- Socket
- JSON
- Queue
- Run the Flask application by executing the
app.py
script. - Access the server through a web browser or an API client.
- Perform login to authenticate yourself.
- Start the server by providing a host and port.
- List connected clients to see their IDs and addresses.
- Send messages to specific clients either with or without waiting for their response.
- Logout to end the session.
/start_server
: POST method to start the server./list_connections
: GET method to list connected clients./login
: GET method to render the login page, POST method to authenticate users./send_message
: POST method to send messages to clients./send_message_and_wait
: POST method to send messages to clients and wait for their response./logout
: GET method to logout the user./
: GET method to render the home page./get_logs
: GET method to retrieve server logs.
- User authentication is required to access most endpoints.
- Passwords are stored in a JSON file (
users.json
) and compared during login.
- Server activities are logged and displayed on the home page.
- Only the last 50 log entries are kept in memory to prevent excessive resource usage.
- This is a basic implementation and may not be suitable for production use without further security and performance enhancements.