-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
36 lines (29 loc) · 1013 Bytes
/
Copy pathapp.py
File metadata and controls
36 lines (29 loc) · 1013 Bytes
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
#!/usr/bin/env python3
"""
NetInfo-Panel - وبسرویس جمعآوری اطلاعات شبکه
"""
from flask import Flask, render_template, request, jsonify
from info_collector import DeviceInfoCollector
import json
app = Flask(__name__)
@app.route('/')
def index():
"""صفحه اصلی پنل"""
return render_template('index.html')
@app.route('/api/info', methods=['POST'])
def get_device_info():
"""API دریافت اطلاعات دستگاه"""
data = request.json
ip = data.get('ip', '').strip()
username = data.get('username', '')
password = data.get('password', '')
if not ip:
return jsonify({'error': 'لطفاً آیپی را وارد کنید'}), 400
try:
collector = DeviceInfoCollector(ip)
info = collector.collect_all(username, password)
return jsonify(info)
except Exception as e:
return jsonify({'error': str(e)}), 500
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0', port=5000)