Spaces:
Sleeping
Sleeping
File size: 1,180 Bytes
765c205 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | """
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)
|