Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
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
b2915503
Commit
b2915503
authored
Mar 27, 2020
by
sheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
store pincode into sqlite
parent
b894a17c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
8 deletions
+66
-8
__pycache__/wifi_utils.cpython-37.pyc
__pycache__/wifi_utils.cpython-37.pyc
+0
-0
app.py
app.py
+22
-1
pincode
pincode
+0
-0
simple_sql.py
simple_sql.py
+37
-0
templates/main_page.html
templates/main_page.html
+5
-6
templates/pincode.html
templates/pincode.html
+2
-1
No files found.
__pycache__/wifi_utils.cpython-37.pyc
View file @
b2915503
No preview for this file type
app.py
View file @
b2915503
...
...
@@ -3,7 +3,7 @@ import json
import
os
import
requests
import
subprocess
import
s
qlite3
import
s
imple_sql
from
wifi_utils
import
*
from
flask_bootstrap
import
Bootstrap
...
...
@@ -17,6 +17,10 @@ recent_dir = os.path.abspath(os.path.dirname(__file__))
wifi_list
=
[]
def
is_encrypted
(
cell
):
if
(
cell
.
security
==
'--'
):
return
False
...
...
@@ -91,8 +95,25 @@ def pin_setup():
return
render_template
(
'pincode.html'
)
@
app
.
route
(
'/pincode_storage'
,
methods
=
[
'POST'
])
def
pin_store
():
pin
=
request
.
form
.
get
(
"pin"
)
print
(
pin
)
if
pin
:
try
:
simple_sql
.
store
(
pin
)
simple_sql
.
findAllPincode
()
except
:
simple_sql
.
init
()
simple_sql
.
store
(
pin
)
return
"OK"
,
200
else
:
return
"Server Error"
,
500
@
app
.
route
(
"/main_page"
,
methods
=
[
'GET'
])
def
main_page
():
return
render_template
(
"main_page.html"
)
if
__name__
==
'__main__'
:
app
.
run
(
host
=
'0.0.0.0'
,
port
=
8080
,
debug
=
True
)
pincode
0 → 100644
View file @
b2915503
File added
simple_sql.py
0 → 100644
View file @
b2915503
import
sqlite3
sql
=
sqlite3
.
connect
(
'pincode'
,
check_same_thread
=
False
)
cur
=
sql
.
cursor
()
def
init
():
global
cur
global
sql
cur
.
execute
(
'''
CREATE TABLE PIN_TABLE
(ID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
PINCODE TEXT NOT NULL);
'''
)
sql
.
commit
()
print
(
"Initial DB table"
)
def
store
(
pin
):
global
cur
global
sql
cmd
=
"INSERT INTO PIN_TABLE (PINCODE) VALUES (?)"
print
(
cmd
)
cur
.
execute
(
"INSERT INTO PIN_TABLE (PINCODE) VALUES (?)"
,
(
pin
,))
sql
.
commit
()
print
(
"Insert into database"
)
return
True
def
findAllPincode
():
global
cur
global
sql
cmd
=
"SELECT * from PIN_TABLE"
ret
=
cur
.
execute
(
cmd
)
pins
=
ret
.
fetchall
()
for
i
in
pins
:
print
(
i
)
templates/main_page.html
View file @
b2915503
...
...
@@ -2,16 +2,15 @@
{% block head %}
{{super()}}
<link
href=
"http://code.jquery.com/ui/1.9.0/themes/ui-darkness/jquery-ui.css"
rel=
"stylesheet"
>
<link
href=
"../static/css/keyboard.css"
rel=
"stylesheet"
>
<link
href=
"../static/css/style.css"
rel=
"stylesheet"
>
<link
rel=
"stylesheet"
href=
"{{url_for('static',filename='css/main.css')}}"
>
{% endblock %}
{% block content %}
<body
>
<div
class=
"col"
>
<button
type=
"submit"
>
Pincode Setup
</button>
<div
class=
"col
-2
"
>
<button
type=
"submit"
class=
"btn btn-primary"
>
Pincode Setup
</button>
</div>
<div
>
<button
type=
"submit"
>
Preference
</button>
<div
class=
"col-2"
>
<button
type=
"submit"
class=
"btn btn-primary"
>
Preference
</button>
</div>
{% block footer %}
...
...
templates/pincode.html
View file @
b2915503
...
...
@@ -57,10 +57,11 @@
if
(
pin_code
.
length
==
6
){
console
.
log
(
pin_code
);
pin
=
pin_code
.
join
(
''
);
data
=
"
pin=
"
+
pin
$
.
ajax
({
type
:
"
POST
"
,
url
:
"
http://localhost:8080/pincode_storage
"
,
data
:
pin
,
data
:
data
,
success
:
function
(
data
,
status
){
alert
(
"
PIN CODE SETUP SUCCESS
"
);
window
.
location
.
href
=
"
http://localhost:8080/main_page
"
;
...
...
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