|
@@ -0,0 +1,55 @@
|
|
|
+from enum import Enum
|
|
|
+from typing import Optional
|
|
|
+from pydantic import BaseModel
|
|
|
+from fastapi import FastAPI, Query, UploadFile, File
|
|
|
+import dataset,json
|
|
|
+from fastapi import FastAPI
|
|
|
+from fastapi.middleware.cors import CORSMiddleware
|
|
|
+app = FastAPI()
|
|
|
+
|
|
|
+origins = [
|
|
|
+ "https://hhh.com.tw"
|
|
|
+ "http://172.105.205.52",
|
|
|
+ "http://172.105.205.52:800020",
|
|
|
+]
|
|
|
+
|
|
|
+app.add_middleware(
|
|
|
+ CORSMiddleware,
|
|
|
+ allow_origins=origins,
|
|
|
+ allow_credentials=True,
|
|
|
+ allow_methods=["*"],
|
|
|
+ allow_headers=["*"],
|
|
|
+)
|
|
|
+db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/hhh?charset=utf8mb4')
|
|
|
+
|
|
|
+class deco_request(BaseModel):
|
|
|
+ id: int
|
|
|
+ name: str
|
|
|
+ email: str
|
|
|
+ phone: str
|
|
|
+ #detail
|
|
|
+ loc: str
|
|
|
+ h_class: str
|
|
|
+ type: str
|
|
|
+ budget: str
|
|
|
+ size: float
|
|
|
+ bed_num: int
|
|
|
+ liv_num: int
|
|
|
+ bath_num: int
|
|
|
+ style: str
|
|
|
+ prefer_date: str
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+@app.post("/deco_request")
|
|
|
+async def create_tags(req:deco_request):
|
|
|
+ tag_table = db['deco_request']
|
|
|
+ pk = tag_table.insert({'name':req.name,'email':req.email,'phone':req.phone,'loc':req.loc
|
|
|
+ ,'h_class':req.h_class,'type':req.type,'budget':req.budget,'size':req.size,'bed_num':req.bed_num
|
|
|
+ ,'liv_num':req.liv_num,'bath_num':req.bath_num,'style':req.style,'prefer_date':req.prefer_date})
|
|
|
+ req.id = pk
|
|
|
+ return req
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|