Spaces:
Sleeping
Sleeping
| import os | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| from flask import Flask, render_template | |
| from pathlib import Path | |
| from db import init_db | |
| from routes.companies import companies_bp | |
| from routes.contacts import contacts_bp | |
| from routes.command import command_bp | |
| from routes.system import stages_bp, activities_bp, stats_bp, columns_bp, settings_bp, bootstrap_bp | |
| from routes.ai import ai_bp | |
| from routes.learning import learning_bp | |
| from routes.stt import stt_bp | |
| from routes.auth import auth_bp | |
| app = Flask(__name__) | |
| app.secret_key = os.environ.get("SECRET_KEY", "prospectiq_secure_dev_session_key_98765") | |
| from db import init_db, is_supabase_active, sync_postgres_sequences | |
| # Ensure database is initialized | |
| if not is_supabase_active(): | |
| db_file = Path(__file__).resolve().parent / "prospectiq.db" | |
| if not db_file.exists() or db_file.stat().st_size == 0: | |
| init_db() | |
| else: | |
| sync_postgres_sequences() | |
| def index(): | |
| return render_template("index.html") | |
| # Register Blueprints | |
| app.register_blueprint(auth_bp, url_prefix='/api/auth') | |
| app.register_blueprint(companies_bp, url_prefix='/api/companies') | |
| app.register_blueprint(contacts_bp, url_prefix='/api/contacts') | |
| app.register_blueprint(stages_bp, url_prefix='/api/stages') | |
| app.register_blueprint(activities_bp, url_prefix='/api/notes') | |
| app.register_blueprint(stats_bp, url_prefix='/api/stats') | |
| app.register_blueprint(columns_bp, url_prefix='/api') | |
| app.register_blueprint(settings_bp, url_prefix='/api/settings') | |
| app.register_blueprint(command_bp, url_prefix='/api/command') | |
| # Register AI Blueprint | |
| app.register_blueprint(ai_bp) | |
| app.register_blueprint(learning_bp, url_prefix='/api/learning') | |
| app.register_blueprint(bootstrap_bp, url_prefix='/api/bootstrap') | |
| app.register_blueprint(stt_bp) | |
| if __name__ == "__main__": | |
| port = int(os.environ.get("PORT", 5000)) | |
| app.run(host="0.0.0.0", port=port, debug=True) | |