-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
42 lines (31 loc) · 1.03 KB
/
main.py
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
from flask import Flask
from flask import render_template
from flask import request
from flask import redirect, url_for
from wakeonlan import send_magic_packet
from flask import session
import os
app = Flask(__name__)
app.secret_key = 'esto-es-una-clave-muy-secreta'
# rutas
@app.route('/', methods=['GET', 'POST'])
def index():
if 'dir_ip' in session:
dir_ip = session['dir_ip']
dir_mac = session['dir_mac']
return render_template('index.html',dir_ip=dir_ip, dir_mac=dir_mac)
else:
return render_template('index.html')
@app.route('/wol', methods=['GET', 'POST'])
def wol():
if request.method == 'POST':
dir_ip = request.form.get('dir_ip')
dir_mac = request.form.get('dir_mac')
session['dir_ip']=dir_ip
session['dir_mac']=dir_mac
send_magic_packet(dir_mac,ip_address=dir_ip, port=9)
#test mac 1C.1B.0D.A2.7C.53
return redirect(url_for('index'))
if __name__ == "__main__":
port = int(os.environ.get("PORT", 5000))
app.run(host='0.0.0.0',port=port)