Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b84f540b43 | ||
|
|
b6f799706f | ||
|
|
cac9dad829 |
BIN
app/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
app/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
BIN
app/__pycache__/main.cpython-312.pyc
Normal file
BIN
app/__pycache__/main.cpython-312.pyc
Normal file
Binary file not shown.
30
app/main.py
30
app/main.py
@@ -13,6 +13,10 @@ import time
|
|||||||
key = "zA2hBU6pv6CIBzkW" # 填写通信密钥
|
key = "zA2hBU6pv6CIBzkW" # 填写通信密钥
|
||||||
mchid = "1561724891" # 特写商户号
|
mchid = "1561724891" # 特写商户号
|
||||||
|
|
||||||
|
# memos 配置
|
||||||
|
MEMOS_API = "https://memos.hackrobot.org/api/v1/users"
|
||||||
|
MEMOS_TOKEN = "eyJhbGciOiJIUzI1NiIsImtpZCI6InYxIiwidHlwIjoiSldUIn0.eyJuYW1lIjoiaGFja3JvYm90IiwiaXNzIjoibWVtb3MiLCJzdWIiOiIxIiwiYXVkIjpbInVzZXIuYWNjZXNzLXRva2VuIl0sImlhdCI6MTc1NzQwNTE0OX0.Idn7kBlxE-CoSOXwWuZ1tHGIRKHAIeDyXSafGS5OHsg"
|
||||||
|
|
||||||
|
|
||||||
# 构造签名函数
|
# 构造签名函数
|
||||||
def sign(attributes):
|
def sign(attributes):
|
||||||
@@ -86,6 +90,32 @@ async def payh5(item: dict):
|
|||||||
# 返回结果中包含`jsapi`字段,该字段的值即是前端发起时所需的6个支付参数
|
# 返回结果中包含`jsapi`字段,该字段的值即是前端发起时所需的6个支付参数
|
||||||
headers = {"content-type": "application/x-www-form-urlencoded"}
|
headers = {"content-type": "application/x-www-form-urlencoded"}
|
||||||
response = requests.post(request_url, data=order, headers=headers)
|
response = requests.post(request_url, data=order, headers=headers)
|
||||||
|
print('response.json()----',response.json())
|
||||||
if response:
|
if response:
|
||||||
print(response.json())
|
print(response.json())
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class CreateUserRequest(BaseModel):
|
||||||
|
username: str = None
|
||||||
|
password: str = None
|
||||||
|
|
||||||
|
@app.post("/create_user")
|
||||||
|
async def create_user(item: CreateUserRequest):
|
||||||
|
timenew = str(int(time.time()))
|
||||||
|
memos_data = {
|
||||||
|
"username": item.username or f"user{timenew}",
|
||||||
|
"password": item.password or "123456",
|
||||||
|
"role": "USER",
|
||||||
|
"state": "NORMAL"
|
||||||
|
}
|
||||||
|
memos_headers = {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Authorization": f"Bearer {MEMOS_TOKEN}"
|
||||||
|
}
|
||||||
|
memos_resp = requests.post(MEMOS_API, json=memos_data, headers=memos_headers)
|
||||||
|
memos_result = memos_resp.json()
|
||||||
|
print('memos_result-',memos_result)
|
||||||
|
return memos_result
|
||||||
|
|
||||||
|
|||||||
4
run.py
4
run.py
@@ -1,6 +1,6 @@
|
|||||||
import uvicorn
|
import uvicorn
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# uvicorn.run("app.main:app", host="0.0.0.0", port=8700, reload=True)
|
uvicorn.run("app.main:app", host="0.0.0.0", port=8700, reload=True)
|
||||||
uvicorn.run("app.main:app", host="127.0.0.1", port=8700, reload=True)
|
# uvicorn.run("app.main:app", host="0.0.0.0", port=8200, reload=True)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user