Spaces:
Sleeping
Sleeping
File size: 1,489 Bytes
8f10d41 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import requests
import json
import os
# current_user: User = Depends(get_current_active_user)):
# oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/token")
# current_user: User = Depends(get_current_active_user)):
# oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/token")
from fastapi import APIRouter, HTTPException
#router = APIRouter()
router = APIRouter(prefix="/appsheet", tags=["appsheet"])
@router.get("/route/appsheet")
def get_senario(id,res):
table = "LOG"
APPSHEET_APPID = os.getenv("APPSHEET_APPID")
APPSHEET_KEY = os.getenv("APPSHEET_KEY")
url = f"https://api.appsheet.com/api/v2/apps/{APPSHEET_APPID}/tables/{table}/Action"
payload = {
"Action": "Add",
"Properties": {},
"Rows":[
{
"コメント":res,
"イメージID":"12121",
"USERNAME":id,
"ユーザーIMG":"122",
}
]}
headers = {
"contentType": "application/json",
"ApplicationAccessKey": APPSHEET_KEY,
"Content-Type": "application/json",
}
messages = []
response = requests.request("POST", url, headers=headers, data=json.dumps(payload))
# print(response)
#print(response)
for key in response:
print(key)
#print(response.text)
print(response.json)
return response.text#.json()
# main input
#res = get_senario("LOG")
#print(res)
#return res
#print(response.json())
if __name__ == "__main__":
get_senario("test","test") |