Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
py12306
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
python
py12306
Commits
a337f972
Commit
a337f972
authored
Jan 12, 2019
by
Jalin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加 web 目录
parent
d5097d23
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
1 deletion
+46
-1
job.py
py12306/user/job.py
+2
-1
__init__.py
py12306/web/__init__.py
+0
-0
__init__.py
py12306/web/handler/__init__.py
+0
-0
user.py
py12306/web/handler/user.py
+17
-0
web.py
py12306/web/web.py
+27
-0
No files found.
py12306/user/job.py
View file @
a337f972
...
@@ -84,6 +84,7 @@ class UserJob:
...
@@ -84,6 +84,7 @@ class UserJob:
if
self
.
is_first_time
()
or
not
self
.
check_user_is_login
():
if
self
.
is_first_time
()
or
not
self
.
check_user_is_login
():
self
.
is_ready
=
False
self
.
is_ready
=
False
if
not
self
.
handle_login
():
return
if
not
self
.
handle_login
():
return
self
.
set_last_heartbeat
()
self
.
is_ready
=
True
self
.
is_ready
=
True
self
.
user_did_load
()
self
.
user_did_load
()
...
@@ -113,7 +114,7 @@ class UserJob:
...
@@ -113,7 +114,7 @@ class UserJob:
def
handle_login
(
self
):
def
handle_login
(
self
):
UserLog
.
print_start_login
(
user
=
self
)
UserLog
.
print_start_login
(
user
=
self
)
self
.
login
()
return
self
.
login
()
def
login
(
self
):
def
login
(
self
):
"""
"""
...
...
py12306/web/__init__.py
0 → 100644
View file @
a337f972
py12306/web/handler/__init__.py
0 → 100644
View file @
a337f972
py12306/web/handler/user.py
0 → 100644
View file @
a337f972
from
flask
import
Blueprint
,
request
from
flask.json
import
jsonify
from
flask_jwt_extended
import
(
JWTManager
,
jwt_required
,
create_access_token
,
get_jwt_identity
)
user
=
Blueprint
(
'user'
,
__name__
)
@
user
.
route
(
'/login'
,
methods
=
[
'POST'
])
def
login
():
username
=
request
.
json
.
get
(
'username'
,
None
)
password
=
request
.
json
.
get
(
'password'
,
None
)
if
username
and
password
and
username
==
'1'
:
access_token
=
create_access_token
(
identity
=
username
)
return
jsonify
(
access_token
=
access_token
)
return
jsonify
({
"msg"
:
"用户名或密码错误"
}),
401
py12306/web/web.py
0 → 100644
View file @
a337f972
import
json
from
flask
import
Flask
,
request
from
flask_jwt_extended
import
(
JWTManager
,
jwt_required
,
create_access_token
,
get_jwt_identity
)
from
py12306.web.handler.user
import
user
app
=
Flask
(
__name__
)
app
.
register_blueprint
(
user
)
# app.config['JWT_TOKEN_LOCATION'] = ['json']
app
.
config
[
'JWT_SECRET_KEY'
]
=
'super-secret'
# Change this!
jwt
=
JWTManager
(
app
)
@
app
.
route
(
'/'
,
methods
=
[
'GET'
])
def
test
():
print
(
111111
)
def
run
(
port
=
8080
):
app
.
run
(
debug
=
True
,
port
=
port
if
port
else
8080
,
host
=
'0.0.0.0'
)
if
__name__
==
'__main__'
:
run
()
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