Skip to content
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

Merged
merged 6 commits into from
May 12, 2024
Merged

fastapi demo #46

merged 6 commits into from
May 12, 2024

Conversation

longsihua2003
Copy link
Collaborator

About the addition of fastapi

Copy link

@github-actions github-actions bot left a 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 🎉🎊 !

@Undertone0809
Copy link
Owner

run make format to optimize code style

ecjtu/ecjtu_api/api.py Outdated Show resolved Hide resolved
@@ -0,0 +1,18 @@
#TODO
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

@@ -0,0 +1,12 @@
import base64
# from ecjtu.client import _get_enc_password
KEY = "zxcvbnmasdgfhjklpoiuytrewq"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove useless code

@@ -0,0 +1,5 @@
from pydantic import BaseModel, Field
Copy link
Owner

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.

Comment on lines 1 to 11
"""
构建response返回结果
{
"code": 200,
"msg": "success",
"data": {
"name": "张三",
"age": 18
}
}
"""
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

Comment on lines 14 to 15
client = ECJTU(stud_id=args.stud_id, password=args.pwd)
client.start_api_server(port=args.port)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix old code

# 启动api服务
def start_api_server():
import uvicorn
uvicorn.run(app, host="127.0.0.1", port=8080)
Copy link
Owner

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.

def cookies_tolist(cookies: Optional[CookieTypes]):
cookies_list = []
for cookie in cookies.jar:
dict = {
Copy link
Owner

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.

@Undertone0809
Copy link
Owner

Add usage In readme


from ecjtu.client import ECJTU

from . import auth, middle, respose_result, schema
Copy link
Owner

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...

return create_tokens(stud_id, pwd)[0]


# 验证和读取access_token的stud_id
Copy link
Owner

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.

Screenshot_2024-05-09-14-28-14-067_com.android.chrome.jpg

class ResponseResult:
@staticmethod
def success(
data: Union[Dict[str, Any], Any] = None, msg: str = "success"
Copy link
Owner

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

@Undertone0809
Copy link
Owner

lgtm

@Undertone0809 Undertone0809 merged commit d483e4e into Undertone0809:main May 12, 2024
3 checks passed
@Undertone0809 Undertone0809 added documentation Improvements or additions to documentation enhancement New feature or request labels May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants