Browse Source

Features added

master
parent
commit
4cd9087dc5
  1. 1
      config/settings.py
  2. 10
      create_passwd.sh
  3. 27
      guestwifi/views/frontend.py
  4. 2
      run.py

1
config/settings.py

@ -1 +1,2 @@
DEBUG=True
HOME_DIR="/home/guestwifi"

10
create_passwd.sh

@ -0,0 +1,10 @@
#!/bin/bash
WLANPSK=$(dd if=/dev/urandom count=1 status=none|tr -d -c 'a-z'|cut -b1-10)
#sed -ie "s/wpa_passphrase=.*/wpa_passphrase=${WLANPSK}/" /etc/hostapd/hostapd.conf
qrencode -t PNG -o /home/guestwifi/android.png -s 4 "WIFI:T:WPA;S:Guest_Krawuzi;P:${WLANPSK};H:false;"
qrencode -t PNG -o /home/guestwifi/windows.png -s 4 "WIFI;T:WPA;S:Guest_Krawuzi;P:${WLANPSK};H:false;"
cat > /home/guestwifi/wlan.cfg <<EOF
[WLAN]
wlanssid=Guest_Krawuzi
wlanpsk=${WLANPSK}
EOF

27
guestwifi/views/frontend.py

@ -1,13 +1,34 @@
from flask import Blueprint, request, json
from flask import Blueprint, request, json, send_file
from configparser import ConfigParser
#from dicttoxml import dicttoxml
from flask import render_template
page = Blueprint('frontend', __name__)
@page.route('/enable')
@page.route('/enable-wifi')
def enable_wifi():
return "test"
@page.route('/disable')
@page.route('/disable-wifi')
def disable_wifi():
return "test"
@page.route('/get-wifissid')
def get_wifi_ssid():
wlancfg = ConfigParser()
wlancfg.read('/home/guestwifi/wlan.cfg')
return wlancfg.get('WLAN','wlanssid')
@page.route('/get-wifipwd')
def get_wifi_pwd():
wlancfg = ConfigParser()
wlancfg.read('/home/guestwifi/wlan.cfg')
return wlancfg.get('WLAN','wlanpsk')
@page.route('/get-qrandroid')
def get_qr_android():
return send_file("/home/guestwifi/android.png")
@page.route('/get-qrwindows')
def get_qr_windows():
return send_file("/home/guestwifi/windows.png")

2
run.py

@ -1,3 +1,3 @@
from guestwifi import app
app.run()
app.run('0.0.0.0')
Loading…
Cancel
Save