Spaces:
Sleeping
Sleeping
Commit
·
6159237
1
Parent(s):
8d9d6f6
Update main.py
Browse files
main.py
CHANGED
@@ -36,6 +36,11 @@ class InputImage(BaseModel):
|
|
36 |
cfg: int = 7
|
37 |
seed: int = -1
|
38 |
|
|
|
|
|
|
|
|
|
|
|
39 |
#--------------------------------------------------- Generazione TESTO ------------------------------------------------------
|
40 |
@app.post("/Genera")
|
41 |
def read_root(request: Request, input_data: InputData):
|
@@ -106,6 +111,16 @@ def generate_image(request: Request, input_data: InputImage):
|
|
106 |
return {"error": "Errore interno del server persistente"}
|
107 |
return {"error": "Numero massimo di tentativi raggiunto"}
|
108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
@app.get("/")
|
110 |
def read_general():
|
111 |
return {"response": "Benvenuto. Per maggiori info: https://matteoscript-fastapi.hf.space/docs"}
|
|
|
36 |
cfg: int = 7
|
37 |
seed: int = -1
|
38 |
|
39 |
+
class RiattivaSpazio(BaseModel):
|
40 |
+
nomeSpazio: str
|
41 |
+
input: str = ''
|
42 |
+
api_name: str = "/chat"
|
43 |
+
|
44 |
#--------------------------------------------------- Generazione TESTO ------------------------------------------------------
|
45 |
@app.post("/Genera")
|
46 |
def read_root(request: Request, input_data: InputData):
|
|
|
111 |
return {"error": "Errore interno del server persistente"}
|
112 |
return {"error": "Numero massimo di tentativi raggiunto"}
|
113 |
|
114 |
+
#--------------------------------------------------- API Spaces (per riattivarli) ------------------------------------------------------
|
115 |
+
@app.post("/RiattivaSpazio")
|
116 |
+
def generate_image(request: Request, input_data: RiattivaSpazio):
|
117 |
+
client = Client(input_data.nomeSpazio)
|
118 |
+
result = client.predict(
|
119 |
+
input_data.input,
|
120 |
+
api_name=input_data.api_name
|
121 |
+
)
|
122 |
+
return {"response": "Spazio riattivato"}
|
123 |
+
|
124 |
@app.get("/")
|
125 |
def read_general():
|
126 |
return {"response": "Benvenuto. Per maggiori info: https://matteoscript-fastapi.hf.space/docs"}
|