-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun_api.py
More file actions
51 lines (39 loc) · 1.44 KB
/
Copy pathrun_api.py
File metadata and controls
51 lines (39 loc) · 1.44 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
Standalone API server for Streamlet Connector.
Serves media data and video files without UI.
Usage:
python run_api.py [--host HOST] [--port PORT]
Default: localhost:5000
"""
import sys
import os
import argparse
# Add the project root to the Python path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from src.api import CustomAPI
from src.media_database import MediaDatabase
def main():
parser = argparse.ArgumentParser(description='Streamlet Connector API Server')
parser.add_argument('--host', default='0.0.0.0', help='Host to bind to (default: 0.0.0.0)')
parser.add_argument('--port', type=int, default=5000, help='Port to bind to (default: 5000)')
args = parser.parse_args()
# Initialize database
database = MediaDatabase()
# Create and run API
api = CustomAPI(host=args.host, port=args.port, database=database)
print(f"\n{'='*60}")
print(f"Streamlet Connector API Server")
print(f"{'='*60}")
print(f"Database: {len(database.get_all_items())} items loaded")
print(f"Server: http://{args.host}:{args.port}")
print(f"Demo: http://{args.host}:{args.port}/demo")
print(f"{'='*60}\n")
print("💡 Otevřete v prohlížeči pro web demo!")
print(f" http://localhost:{args.port}\n")
try:
api.run()
except KeyboardInterrupt:
print("\n\nShutting down API server...")
sys.exit(0)
if __name__ == '__main__':
main()