by mansourkhran
TawnChat
import logging
from gunicorn.app.base import BaseApplication
from app_init import app
# IMPORT ALL ROUTES
from routes import *
# Setup logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
class StandaloneApplication(BaseApplication):
def __init__(self, app, options=None):
self.application = app
self.options = options or {}
super().__init__()
def load_config(self):
# Apply configuration to Gunicorn
for key, value in self.options.items():
if key in self.cfg.settings and value is not None:
self.cfg.set(key.lower(), value)
Created: | Last Updated:
Here's a step-by-step guide for using the TawnChat template:
Introduction
TawnChat is a real-time messaging application with user authentication and an integrated AI assistant. This template provides a foundation for building a web-based chat platform with features like user profiles, friend management, and private messaging.
Getting Started
To begin using the TawnChat template:
- Click the "Start with this Template" button in the Lazy Builder interface.
Test the Application
After starting with the template:
- Click the "Test" button in the Lazy Builder interface.
- This will initiate the deployment process and launch the Lazy CLI.
Using the Application
Once the application is deployed, you can access and use TawnChat through the provided server link. Here's how to navigate the main features:
- User Registration and Authentication:
- When you first access the application, you'll be prompted to log in or register.
-
The authentication is handled automatically through the
flask_app_authenticator
ability. -
Set Username:
- After logging in for the first time, you'll be prompted to set a username.
- Choose a username between 3-20 characters, containing only letters, numbers, and underscores.
-
This username cannot be changed later.
-
Profile Management:
-
Navigate to the Profile section to update your bio and choose between light and dark themes.
-
Adding Friends:
- Go to the Friends section to add new friends by their username.
-
You can also manage friend requests in this section.
-
Messaging:
- Access the Messages section to view your recent chats.
-
Click on a friend's name to open a chat window and start messaging.
-
AI Assistant:
- An AI bot named "TawnBot" will automatically send a welcome message to new users.
- You can interact with TawnBot like any other user in the chat interface.
Customization and Integration
To further customize or integrate TawnChat:
- Styling:
-
Modify the CSS files (
profile.css
,landing.css
,sidebar.css
,chat.css
) to change the application's appearance. -
Database:
-
The application uses SQLite by default. If you need to switch to a different database, update the
SQLALCHEMY_DATABASE_URI
inapp_init.py
. -
Authentication:
-
The current setup uses a custom authentication system. If you need to integrate with a specific auth provider, modify the
flask_app_authenticator
call inapp_init.py
. -
AI Integration:
- To enhance the AI assistant's capabilities, you can modify the bot's responses in the
set_username_route
function inroutes.py
.
Remember, all changes and deployments are handled through the Lazy platform, so you don't need to worry about server setup or environment configuration.
Here are the top 5 business benefits or applications of this template:
Template Benefits
-
Secure User Authentication: The template provides a robust user authentication system, ensuring that only authorized users can access the messaging platform. This enhances security and protects user data, making it suitable for businesses that require confidential communication.
-
Real-Time Messaging Capabilities: With its real-time messaging feature, this template enables instant communication between users. This can greatly improve collaboration and productivity within teams or between businesses and their clients.
-
AI Assistant Integration: The inclusion of an AI assistant (TawnBot) adds significant value by providing instant support, answering queries, and potentially automating certain tasks. This can reduce the workload on human support staff and improve user experience.
-
User Profile Management: The template allows users to set and manage their profiles, including bios and theme preferences. This personalization can increase user engagement and satisfaction with the platform.
-
Scalable Friend Network: The ability to add friends via usernames and manage friend requests creates a scalable network effect. This feature can be particularly beneficial for social networking applications or business communication platforms that rely on connecting users.
Technologies




