Spaces:
Sleeping

backendAPI / run_server.py
changweikoy's picture
Fix sentiment model VersionMismatch and clean_text reference issue
765c205
Raw History Blame Contribute Delete
1.18 kB
"""
Simple server launcher without emojis to avoid Unicode encoding issues
"""
import sys
import os
# Set UTF-8 encoding
if sys.platform == 'win32':
import codecs
sys.stdout = codecs.getwriter('utf-8')(sys.stdout.detach())
sys.stderr = codecs.getwriter('utf-8')(sys.stderr.detach())
# Import the Flask app
from app import app, SERVER_IP, SERVER_PORT, sentiment_analyzer, GEMINI_API_KEY
print("\nStarting Gemini AI Journaling Backend...")
print(f"API Key configured: {'YES' if GEMINI_API_KEY else 'NO'}")
print(f"Server will be available at: http://{SERVER_IP}:{SERVER_PORT}")
print(f"Also accessible via: http://localhost:{SERVER_PORT}")
# Initialize sentiment analysis model on startup
print("\nInitializing sentiment analysis model...")
if sentiment_analyzer.initialize():
print(f"Sentiment analysis ready! (Accuracy: {sentiment_analyzer.model_accuracy:.2%})")
print(f"Classes: {', '.join(sentiment_analyzer.classes)}")
else:
print("WARNING: Sentiment analysis initialization failed")
print("\n" + "="*60)
print("Server starting...")
print("="*60 + "\n")
# Start the server
app.run(debug=True, host='0.0.0.0', port=SERVER_PORT, use_reloader=False)