Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
postbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Wen Wei Li
postbox
Commits
7261bf8e
Commit
7261bf8e
authored
Mar 25, 2020
by
Wen Wei Li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
beautify the interface by lora
parent
3a8a3a99
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
24 deletions
+75
-24
app.py
app.py
+30
-12
static/css/main.css
static/css/main.css
+3
-3
templates/error.html
templates/error.html
+1
-0
templates/wifi.html
templates/wifi.html
+41
-9
No files found.
app.py
View file @
7261bf8e
...
@@ -12,18 +12,29 @@ recent_dir = os.path.abspath(os.path.dirname(__file__))
...
@@ -12,18 +12,29 @@ recent_dir = os.path.abspath(os.path.dirname(__file__))
wifi_list
=
[]
wifi_list
=
[]
wifi_name_list
=
[]
wifi_name_list
=
[]
def
wifi_scan
():
def
wifi_scan
():
wifi_list
.
clear
()
wifi_name_list
.
clear
()
wifi_name_list
.
append
(
"TEST WIFI"
)
wireless
=
Wireless
()
wireless
=
Wireless
()
cells
=
Cell
.
all
(
'wlan0'
)
cells
=
Cell
.
all
(
'wlan0'
)
for
cell
in
cells
:
for
cell
in
cells
:
wifi_list
.
append
(
cell
)
wifi_list
.
append
(
cell
)
wifi_name_list
.
append
(
cell
.
ssid
)
wifi_name_list
.
append
(
cell
.
ssid
)
def
print_wifi
():
for
i
in
wifi_name_list
:
print
(
i
)
def
getWifiCell
(
ssid
):
def
is_encrypted
(
ssid
):
for
i
in
wifi_list
:
for
i
in
wifi_list
:
if
i
.
ssid
==
ssid
:
if
i
.
ssid
==
ssid
:
return
i
return
None
def
is_encrypted
(
cell
):
if
cell
is
not
None
:
return
i
.
encrypted
return
i
.
encrypted
else
:
return
None
return
None
def
connect_wifi
(
ssid
,
password
):
def
connect_wifi
(
ssid
,
password
):
...
@@ -43,17 +54,24 @@ def initial():
...
@@ -43,17 +54,24 @@ def initial():
return
'HTTP OK'
return
'HTTP OK'
@
app
.
route
(
'/wifi_
configure
'
)
@
app
.
route
(
'/wifi_
scan
'
)
def
wifi_config
ure
():
def
wifi_config
():
wifi_scan
()
wifi_scan
()
return
render_template
(
'wifi.html'
,
data
=
wifi_name_list
)
return
render_template
(
'wifi.html'
,
data
=
wifi_name_list
)
@
app
.
route
(
'/wifi_pass'
)
@
app
.
route
(
'/wifi_pass/<string:ssid>'
,
methods
=
[
'GET'
])
def
wifi_pass
():
def
wifi_pass
(
ssid
):
print
(
"Ready for Connecting to {}"
.
format
(
ssid
))
print_wifi
()
cell
=
getWifiCell
(
ssid
)
print
(
cell
.
ssid
)
if
(
cell
is
not
None
):
if
(
is_encrypted
(
cell
)
==
True
):
return
render_template
(
'index.html'
)
return
render_template
(
'index.html'
)
else
:
return
render_template
(
'index.html'
,
data
=
False
)
else
:
return
"{}"
.
format
(
cell
.
ssid
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
app
.
run
(
host
=
'0.0.0.0'
,
port
=
8080
,
debug
=
True
)
app
.
run
(
host
=
'0.0.0.0'
,
port
=
8080
,
debug
=
True
)
static/css/main.css
View file @
7261bf8e
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
width
:
auto
;
width
:
auto
;
height
:
50px
;
height
:
50px
;
}
}
.btn
{
width
:
auto
;
td
{
height
:
50px
;
cursor
:
pointer
;
}
}
templates/error.html
0 → 100644
View file @
7261bf8e
ERROR
templates/wifi.html
View file @
7261bf8e
...
@@ -3,32 +3,37 @@
...
@@ -3,32 +3,37 @@
{% block head %}
{% block head %}
{{super()}}
{{super()}}
<link
href=
"{{url_for('static',filename='css/
keyboard
.css')}}"
rel=
"stylesheet"
>
<link
href=
"{{url_for('static',filename='css/
main
.css')}}"
rel=
"stylesheet"
>
{% endblock %}
{% endblock %}
{% block content %}
{% block content %}
<div
class=
"container pad-t-50"
>
<h2
class=
"text-muted text-center m-5"
>
WIFI SSID
</h2>
<table
class=
"table table-striped"
>
<div
class=
"container m-5"
>
<table
class=
"table table-hover"
>
<thead>
<thead>
<tr>
<tr>
<th
scope=
"col"
>
WIFI SSID
</th>
<th
scope=
"col"
class=
"text-center"
>
Index
</th>
<th
scope=
"col"
class=
"text-center"
>
SSID
</th>
</tr>
</tr>
</thead>
</thead>
<tbody>
<tbody>
{% for ssid in data %}
{% for ssid in data %}
<tr>
<tr
onclick=
"getSSID(this,'{{ssid}}')"
>
<td>
{{ssid}}
</td>
<td
class=
"text-center"
>
{{loop.index}}
</td>
<td
class=
"text-center"
>
{{ssid}}
</td>
</tr>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</tbody>
</table>
</table>
<button
type=
"button"
id=
"confirm"
class=
"btn btn-danger"
>
confirm
</button>
<div
class=
"col text-center"
>
</div>
<button
type=
"button"
id=
"button"
class=
"btn btn-danger btn-lg"
>
confirm
</button>
</div>
</div>
{% block footer %}
{% block footer %}
<footer
class=
"footer"
>
<footer
class=
"footer"
>
<div
class=
"footer navbar-fixed-bottom text-center"
>
<div
class=
"footer navbar-fixed-bottom text-center"
>
<p
class=
"text-muted"
>
©
N
CKU Partner
</p>
<p
class=
"text-muted"
>
©
N
TUST PRLAB
</p>
</div>
</div>
</footer>
</footer>
{% endblock footer %}
{% endblock footer %}
...
@@ -36,7 +41,34 @@
...
@@ -36,7 +41,34 @@
{% block scripts %}
{% block scripts %}
{{super()}}
{{super()}}
<script>
var
_ssid
=
""
;
var
prev_item
=
null
;
function
getSSID
(
tableRow
,
ssid
){
console
.
log
(
tableRow
)
if
(
prev_item
!=
null
)
{
prev_item
.
style
.
backgroundColor
=
'
#FFFFFF
'
;
}
if
(
prev_item
==
tableRow
){
prev_item
=
null
;
tableRow
.
style
.
backgroundColor
=
'
#FFFFFF
'
;
_ssid
=
""
;
}
else
{
prev_item
=
tableRow
;
tableRow
.
style
.
backgroundColor
=
'
#eaeaea
'
;
_ssid
=
ssid
;
}
console
.
log
(
ssid
);
};
$
(
'
#button
'
).
click
(
function
(){
console
.
log
(
_ssid
);
prev_item
.
style
.
backgroundColor
=
'
#FFFFFF
'
;
prev_item
=
null
;
});
</script>
{% endblock %}
{% endblock %}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment