MCPcopy
hub / github.com/Zie619/n8n-workflows / run_server

Function run_server

api_server.py:774–818  ·  view source on GitHub ↗

Run the FastAPI server.

(host: str = "127.0.0.1", port: int = 8000, reload: bool = False)

Source from the content-addressed store, hash-verified

772
773
774def run_server(host: str = "127.0.0.1", port: int = 8000, reload: bool = False):
775 """Run the FastAPI server."""
776 # Ensure static directory exists
777 create_static_directory()
778
779 # Debug: Check database connectivity
780 try:
781 stats = db.get_stats()
782 print(f"✅ Database connected: {stats['total']} workflows found")
783 if stats["total"] == 0:
784 print("🔄 Database is empty. Indexing workflows...")
785 db.index_all_workflows()
786 stats = db.get_stats()
787 except Exception as e:
788 print(f"❌ Database error: {e}")
789 print("🔄 Attempting to create and index database...")
790 try:
791 db.index_all_workflows()
792 stats = db.get_stats()
793 print(f"✅ Database created: {stats['total']} workflows indexed")
794 except Exception as e2:
795 print(f"❌ Failed to create database: {e2}")
796 stats = {"total": 0}
797
798 # Debug: Check static files
799 static_path = Path("static")
800 if static_path.exists():
801 files = list(static_path.glob("*"))
802 print(f"✅ Static files found: {[f.name for f in files]}")
803 else:
804 print(f"❌ Static directory not found at: {static_path.absolute()}")
805
806 print("🚀 Starting N8N Workflow Documentation API")
807 print(f"📊 Database contains {stats['total']} workflows")
808 print(f"🌐 Server will be available at: http://{host}:{port}")
809 print(f"📁 Static files at: http://{host}:{port}/static/")
810
811 uvicorn.run(
812 "api_server:app",
813 host=host,
814 port=port,
815 reload=reload,
816 access_log=True, # Enable access logs for debugging
817 log_level="info",
818 )
819
820
821if __name__ == "__main__":

Callers 1

api_server.pyFile · 0.85

Calls 4

create_static_directoryFunction · 0.85
get_statsMethod · 0.80
index_all_workflowsMethod · 0.80
runMethod · 0.80

Tested by

no test coverage detected