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
An error occurred while fetching merge requests data.
Commit
7261bf8e
authored
5 years ago
by
Wen Wei Li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
beautify the interface by lora
parent
3a8a3a99
Changes
4
Hide 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,20 +12,31 @@ recent_dir = os.path.abspath(os.path.dirname(__file__))
wifi_list
=
[]
wifi_name_list
=
[]
def
wifi_scan
():
wifi_list
.
clear
()
wifi_name_list
.
clear
()
wifi_name_list
.
append
(
"TEST WIFI"
)
wireless
=
Wireless
()
cells
=
Cell
.
all
(
'wlan0'
)
for
cell
in
cells
:
wifi_list
.
append
(
cell
)
wifi_name_list
.
append
(
cell
.
ssid
)
def
print_wifi
():
for
i
in
wifi_name_list
:
print
(
i
)
def
is_encrypted
(
ssid
):
def
getWifiCell
(
ssid
):
for
i
in
wifi_list
:
if
i
.
ssid
==
ssid
:
return
i
.
encrypted
if
i
.
ssid
==
ssid
:
return
i
return
None
def
is_encrypted
(
cell
):
if
cell
is
not
None
:
return
i
.
encrypted
else
:
return
None
def
connect_wifi
(
ssid
,
password
):
ret
=
wireless
.
connect
(
ssid
,
password
)
if
ret
==
False
:
...
...
@@ -43,17 +54,24 @@ def initial():
return
'HTTP OK'
@
app
.
route
(
'/wifi_
configure
'
)
def
wifi_config
ure
():
@
app
.
route
(
'/wifi_
scan
'
)
def
wifi_config
():
wifi_scan
()
return
render_template
(
'wifi.html'
,
data
=
wifi_name_list
)
@
app
.
route
(
'/wifi_pass'
)
def
wifi_pass
():
return
render_template
(
'index.html'
)
@
app
.
route
(
'/wifi_pass/<string:ssid>'
,
methods
=
[
'GET'
])
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'
)
else
:
return
render_template
(
'index.html'
,
data
=
False
)
else
:
return
"{}"
.
format
(
cell
.
ssid
)
if
__name__
==
'__main__'
:
app
.
run
(
host
=
'0.0.0.0'
,
port
=
8080
,
debug
=
True
)
This diff is collapsed.
Click to expand it.
static/css/main.css
View file @
7261bf8e
...
...
@@ -6,7 +6,7 @@
width
:
auto
;
height
:
50px
;
}
.btn
{
width
:
auto
;
height
:
50px
;
td
{
cursor
:
pointer
;
}
This diff is collapsed.
Click to expand it.
templates/error.html
0 → 100644
View file @
7261bf8e
ERROR
This diff is collapsed.
Click to expand it.
templates/wifi.html
View file @
7261bf8e
...
...
@@ -3,32 +3,37 @@
{% block head %}
{{super()}}
<link
href=
"{{url_for('static',filename='css/
keyboard
.css')}}"
rel=
"stylesheet"
>
<link
href=
"{{url_for('static',filename='css/
main
.css')}}"
rel=
"stylesheet"
>
{% endblock %}
{% block content %}
<div
class=
"container pad-t-50"
>
<table
class=
"table table-striped"
>
<h2
class=
"text-muted text-center m-5"
>
WIFI SSID
</h2>
<div
class=
"container m-5"
>
<table
class=
"table table-hover"
>
<thead>
<tr>
<th
scope=
"col"
>
WIFI SSID
</th>
<th
scope=
"col"
class=
"text-center"
>
Index
</th>
<th
scope=
"col"
class=
"text-center"
>
SSID
</th>
</tr>
</thead>
<tbody>
{% for ssid in data %}
<tr>
<td>
{{ssid}}
</td>
<tr
onclick=
"getSSID(this,'{{ssid}}')"
>
<td
class=
"text-center"
>
{{loop.index}}
</td>
<td
class=
"text-center"
>
{{ssid}}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<button
type=
"button"
id=
"confirm"
class=
"btn btn-danger"
>
confirm
</button>
</div>
<div
class=
"col text-center"
>
<button
type=
"button"
id=
"button"
class=
"btn btn-danger btn-lg"
>
confirm
</button>
</div>
</div>
{% block footer %}
<footer
class=
"footer"
>
<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>
</footer>
{% endblock footer %}
...
...
@@ -36,7 +41,34 @@
{% block scripts %}
{{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 %}
This diff is collapsed.
Click to expand it.
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