-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fastapi demo #46
fastapi demo #46
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @longsihua2003, thanks for opening your first pull request 😊! We really appreciate your work. Happy Coding 🎉🎊 !
run |
ecjtu/ecjtu_api/server.py
Outdated
@@ -0,0 +1,18 @@ | |||
#TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
ecjtu/ecjtu_api/auth.py
Outdated
@@ -0,0 +1,12 @@ | |||
import base64 | |||
# from ecjtu.client import _get_enc_password | |||
KEY = "zxcvbnmasdgfhjklpoiuytrewq" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove useless code
ecjtu/ecjtu_api/ecjtu_schema.py
Outdated
@@ -0,0 +1,5 @@ | |||
from pydantic import BaseModel, Field |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file named schema is enough.
ecjtu/ecjtu_api/respose_result.py
Outdated
""" | ||
构建response返回结果 | ||
{ | ||
"code": 200, | ||
"msg": "success", | ||
"data": { | ||
"name": "张三", | ||
"age": 18 | ||
} | ||
} | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment
ecjtu/ecjtu_api/server.py
Outdated
client = ECJTU(stud_id=args.stud_id, password=args.pwd) | ||
client.start_api_server(port=args.port) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix old code
ecjtu/ecjtu_api/api.py
Outdated
# 启动api服务 | ||
def start_api_server(): | ||
import uvicorn | ||
uvicorn.run(app, host="127.0.0.1", port=8080) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The port must be configurable.
ecjtu/utils/cookie.py
Outdated
def cookies_tolist(cookies: Optional[CookieTypes]): | ||
cookies_list = [] | ||
for cookie in cookies.jar: | ||
dict = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dict is a key word. Change the name.
Add usage In readme |
ecjtu/ecjtu_api/api.py
Outdated
|
||
from ecjtu.client import ECJTU | ||
|
||
from . import auth, middle, respose_result, schema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from ecjtu.ecjtu_API import...
ecjtu/ecjtu_api/auth.py
Outdated
return create_tokens(stud_id, pwd)[0] | ||
|
||
|
||
# 验证和读取access_token的stud_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All comments use Google code guidelines. Use function type comment.
https://google.github.io/styleguide/pyguide.html
You can set Google code style in pycharm.
ecjtu/ecjtu_api/respose_result.py
Outdated
class ResponseResult: | ||
@staticmethod | ||
def success( | ||
data: Union[Dict[str, Any], Any] = None, msg: str = "success" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes me a little confused. Any means any type. It doesn't make sense to go with Union
lgtm |
About the addition of fastapi