| | from flask import Flask, render_template, request, jsonify
|
| | from flask_cors import CORS
|
| | from datetime import datetime
|
| | import json
|
| | import os
|
| |
|
| | app = Flask(__name__)
|
| | CORS(app)
|
| |
|
| |
|
| | current_urls = {
|
| | 'base_url': '',
|
| | 'last_updated': '',
|
| | 'portals': []
|
| | }
|
| |
|
| | @app.route('/')
|
| | def index():
|
| | """Main AR Portal Dashboard"""
|
| | return render_template('ar_dashboard.html',
|
| | base_url=current_urls.get('base_url', ''),
|
| | last_updated=current_urls.get('last_updated', ''),
|
| | portals=current_urls.get('portals', []))
|
| |
|
| | @app.route('/api/update-urls', methods=['POST'])
|
| | def update_urls():
|
| | """API endpoint to receive ngrok URLs from the system"""
|
| | try:
|
| | data = request.get_json()
|
| |
|
| | if not data or 'base_url' not in data:
|
| | return jsonify({'error': 'base_url is required'}), 400
|
| |
|
| | base_url = data['base_url']
|
| | timestamp = datetime.now().isoformat()
|
| |
|
| |
|
| | portals = [
|
| | {
|
| | 'name': 'Portal Control',
|
| | 'url': f'{base_url}/portal',
|
| | 'path': '/portal',
|
| | 'icon': 'settings',
|
| | 'color': 'blue',
|
| | 'description': 'Main control center'
|
| | },
|
| | {
|
| | 'name': 'SciBERT Analysis',
|
| | 'url': f'{base_url}/analysis',
|
| | 'path': '/analysis',
|
| | 'icon': 'bar-chart-3',
|
| | 'color': 'green',
|
| | 'description': 'Scientific analysis tools'
|
| | },
|
| | {
|
| | 'name': 'Conductor',
|
| | 'url': f'{base_url}/conductor',
|
| | 'path': '/conductor',
|
| | 'icon': 'cpu',
|
| | 'color': 'purple',
|
| | 'description': 'System orchestration'
|
| | },
|
| | {
|
| | 'name': 'Economic Modal',
|
| | 'url': f'{base_url}/economic',
|
| | 'path': '/economic',
|
| | 'icon': 'dollar-sign',
|
| | 'color': 'yellow',
|
| | 'description': 'Economic modeling'
|
| | },
|
| | {
|
| | 'name': 'War Modal',
|
| | 'url': f'{base_url}/war',
|
| | 'path': '/war',
|
| | 'icon': 'shield',
|
| | 'color': 'red',
|
| | 'description': 'Strategic analysis'
|
| | },
|
| | {
|
| | 'name': 'Disease Modal',
|
| | 'url': f'{base_url}/disease',
|
| | 'path': '/disease',
|
| | 'icon': 'bug',
|
| | 'color': 'orange',
|
| | 'description': 'Disease tracking'
|
| | },
|
| | {
|
| | 'name': 'DeepSeek',
|
| | 'url': f'{base_url}/deepseek',
|
| | 'path': '/deepseek',
|
| | 'icon': 'brain',
|
| | 'color': 'indigo',
|
| | 'description': 'AI deep analysis'
|
| | },
|
| | {
|
| | 'name': 'Image Modal',
|
| | 'url': f'{base_url}/image',
|
| | 'path': '/image',
|
| | 'icon': 'image',
|
| | 'color': 'pink',
|
| | 'description': 'Image processing'
|
| | },
|
| | {
|
| | 'name': 'Drug Development',
|
| | 'url': f'{base_url}/drug',
|
| | 'path': '/drug',
|
| | 'icon': 'pill',
|
| | 'color': 'teal',
|
| | 'description': 'Pharmaceutical research'
|
| | },
|
| | {
|
| | 'name': 'Visual Kinetic',
|
| | 'url': f'{base_url}/visual-kinetic',
|
| | 'path': '/visual-kinetic',
|
| | 'icon': 'eye',
|
| | 'color': 'cyan',
|
| | 'description': 'Visual analytics'
|
| | }
|
| | ]
|
| |
|
| |
|
| | current_urls.update({
|
| | 'base_url': base_url,
|
| | 'last_updated': timestamp,
|
| | 'portals': portals
|
| | })
|
| |
|
| | return jsonify({
|
| | 'success': True,
|
| | 'message': 'URLs updated successfully',
|
| | 'base_url': base_url,
|
| | 'timestamp': timestamp,
|
| | 'portals_count': len(portals)
|
| | })
|
| |
|
| | except Exception as e:
|
| | return jsonify({'error': str(e)}), 500
|
| |
|
| | @app.route('/api/status')
|
| | def status():
|
| | """Get current system status"""
|
| | return jsonify({
|
| | 'status': 'online',
|
| | 'base_url': current_urls.get('base_url', ''),
|
| | 'last_updated': current_urls.get('last_updated', ''),
|
| | 'portals_count': len(current_urls.get('portals', [])),
|
| | 'total_portals': 10
|
| | })
|
| |
|
| | @app.route('/health')
|
| | def health():
|
| | """Health check endpoint"""
|
| | return jsonify({'status': 'healthy', 'timestamp': datetime.now().isoformat()})
|
| |
|
| | if __name__ == '__main__':
|
| | port = int(os.environ.get('PORT', 7860))
|
| | app.run(host='0.0.0.0', port=port, debug=False) |