summaryrefslogtreecommitdiff
path: root/API.py
diff options
context:
space:
mode:
authorKyomotoi <[email protected]>2020-08-02 23:41:54 +0800
committerKyomotoi <[email protected]>2020-08-02 23:41:54 +0800
commit488ccc9b4aaa3327777cb1109edcb3a903832412 (patch)
tree3598e044dcb6588120e02ebaf7d02951be467d35 /API.py
parenta8be7a48c9a672c57b4c7d786a7ad53fd7fbe768 (diff)
downloadATRI-488ccc9b4aaa3327777cb1109edcb3a903832412.tar.gz
ATRI-488ccc9b4aaa3327777cb1109edcb3a903832412.tar.bz2
ATRI-488ccc9b4aaa3327777cb1109edcb3a903832412.zip
[Update] new function
Diffstat (limited to 'API.py')
-rw-r--r--API.py83
1 files changed, 83 insertions, 0 deletions
diff --git a/API.py b/API.py
new file mode 100644
index 0000000..9d9140f
--- /dev/null
+++ b/API.py
@@ -0,0 +1,83 @@
+# -*- coding:utf-8 -*-
+import sqlite3
+
+from fastapi import FastAPI
+from enum import Enum
+
+
+app = FastAPI()
+path_setu = f'ATRI\\splite\\setu\\'
+path_cloudmusic = f'ATRI\\splite\\cloudmusic\\'
+
+class ModelName(str, Enum):
+ alexnet = "normal"
+ resnet = "nearR18"
+ lenet = "r18"
+
+
[email protected]("/setu/{h_type}")
+def get_setu(h_type: str):
+ if h_type == ModelName.alexnet:
+ con = sqlite3.connect(path_setu + 'normal.db')
+ cur = con.cursor()
+ msg = cur.execute('SELECT * FROM normal ORDER BY RANDOM() limit 1;')
+ for i in msg:
+ pid = i[0]
+ title = i[1]
+ tags = i[2]
+ account = i[3]
+ name = i[4]
+ u_id = i[5]
+ user_link = i[6]
+ img = i[7]
+ print('success!')
+ con.commit()
+ con.close()
+ return {"Pid": pid, 0:{"title": title,"tags": tags,"account": account, "name": name,"u_id": u_id, "user_link": user_link, "img": img}}
+
+ elif h_type == ModelName.resnet:
+ con = sqlite3.connect(path_setu + 'nearR18.db')
+ cur = con.cursor()
+ msg = cur.execute('SELECT * FROM nearR18 ORDER BY RANDOM() limit 1;')
+ for i in msg:
+ pid = i[0]
+ title = i[1]
+ tags = i[2]
+ account = i[3]
+ name = i[4]
+ u_id = i[5]
+ user_link = i[6]
+ img = i[7]
+ print('success!')
+ con.commit()
+ con.close()
+ return {"Pid": pid, 0:{"title": title,"tags": tags,"account": account, "name": name,"u_id": u_id, "user_link": user_link, "img": img}}
+
+ elif h_type == ModelName.lenet:
+ con = sqlite3.connect(path_setu + 'r18.db')
+ cur = con.cursor()
+ msg = cur.execute('SELECT * FROM r18 ORDER BY RANDOM() limit 1;')
+ for i in msg:
+ pid = i[0]
+ title = i[1]
+ tags = i[2]
+ account = i[3]
+ name = i[4]
+ u_id = i[5]
+ user_link = i[6]
+ img = i[7]
+ con.commit()
+ con.close()
+ return {"Pid": pid, 0:{"title": title,"tags": tags,"account": account, "name": name,"u_id": u_id, "user_link": user_link, "img": img}}
+
+
[email protected]("/cloudmusic")
+async def Depression():
+ con = sqlite3.connect(path_cloudmusic + 'cloudmusic.db')
+ cur = con.cursor()
+ msg = cur.execute('SELECT * FROM cloudmusic ORDER BY RANDOM() limit 1;')
+ for i in msg:
+ msg = i[0]
+ con.commit()
+ con.close()
+ return {"msg": msg} \ No newline at end of file