Spaces:
Sleeping
Sleeping
fix (app): back to post and https
Browse files
app/server_factory_predictor.py
CHANGED
|
@@ -17,7 +17,7 @@ app.mount("/app/static", StaticFiles(directory="static"), name="static")
|
|
| 17 |
app.add_middleware(
|
| 18 |
CORSMiddleware,
|
| 19 |
allow_origins=["http://127.0.0.1:5173","http://localhost:5173","http://127.0.0.1:7860",
|
| 20 |
-
"http://localhost:7860","http://0.0.0.0:7860", "
|
| 21 |
allow_credentials=True,
|
| 22 |
allow_methods=["*"],
|
| 23 |
allow_headers=["*"],
|
|
@@ -48,7 +48,7 @@ def train_model():
|
|
| 48 |
except Exception as e:
|
| 49 |
training_status = f"Failed: {str(e)}"
|
| 50 |
|
| 51 |
-
@app.
|
| 52 |
async def train(background_tasks: BackgroundTasks):
|
| 53 |
background_tasks.add_task(train_model)
|
| 54 |
return {"message": "Training started in the background"}
|
|
@@ -67,7 +67,7 @@ async def predict(temperature: int, pressure: int):
|
|
| 67 |
except Exception as e:
|
| 68 |
raise HTTPException(status_code=500, detail=str(e)) from e
|
| 69 |
|
| 70 |
-
@app.
|
| 71 |
async def inform_temperature(value: int):
|
| 72 |
if training_status != "Completed":
|
| 73 |
raise HTTPException(status_code=400, detail="Model not trained yet")
|
|
@@ -77,7 +77,7 @@ async def inform_temperature(value: int):
|
|
| 77 |
except Exception as e:
|
| 78 |
raise HTTPException(status_code=500, detail=str(e)) from e
|
| 79 |
|
| 80 |
-
@app.
|
| 81 |
async def inform_pressure(value: int):
|
| 82 |
if training_status != "Completed":
|
| 83 |
raise HTTPException(status_code=400, detail="Model not trained yet")
|
|
|
|
| 17 |
app.add_middleware(
|
| 18 |
CORSMiddleware,
|
| 19 |
allow_origins=["http://127.0.0.1:5173","http://localhost:5173","http://127.0.0.1:7860",
|
| 20 |
+
"http://localhost:7860","http://0.0.0.0:7860", "https://santanche-factory-ml.hf.space"],
|
| 21 |
allow_credentials=True,
|
| 22 |
allow_methods=["*"],
|
| 23 |
allow_headers=["*"],
|
|
|
|
| 48 |
except Exception as e:
|
| 49 |
training_status = f"Failed: {str(e)}"
|
| 50 |
|
| 51 |
+
@app.post("/train")
|
| 52 |
async def train(background_tasks: BackgroundTasks):
|
| 53 |
background_tasks.add_task(train_model)
|
| 54 |
return {"message": "Training started in the background"}
|
|
|
|
| 67 |
except Exception as e:
|
| 68 |
raise HTTPException(status_code=500, detail=str(e)) from e
|
| 69 |
|
| 70 |
+
@app.post("/inform_temperature")
|
| 71 |
async def inform_temperature(value: int):
|
| 72 |
if training_status != "Completed":
|
| 73 |
raise HTTPException(status_code=400, detail="Model not trained yet")
|
|
|
|
| 77 |
except Exception as e:
|
| 78 |
raise HTTPException(status_code=500, detail=str(e)) from e
|
| 79 |
|
| 80 |
+
@app.post("/inform_pressure")
|
| 81 |
async def inform_pressure(value: int):
|
| 82 |
if training_status != "Completed":
|
| 83 |
raise HTTPException(status_code=400, detail="Model not trained yet")
|
app/static/editor/js/editor-rest.js
CHANGED
|
@@ -6,7 +6,7 @@ Oid.customize('oid:rest', {
|
|
| 6 |
api: {
|
| 7 |
oas: {
|
| 8 |
paths: {
|
| 9 |
-
'
|
| 10 |
'post': {
|
| 11 |
operationId: 'train',
|
| 12 |
parameters: [
|
|
@@ -19,7 +19,7 @@ Oid.customize('oid:rest', {
|
|
| 19 |
]
|
| 20 |
}
|
| 21 |
},
|
| 22 |
-
'
|
| 23 |
'get': {
|
| 24 |
operationId: 'predict',
|
| 25 |
parameters: [
|
|
@@ -48,13 +48,13 @@ Oid.customize('oid:rest', {
|
|
| 48 |
api: {
|
| 49 |
oas: {
|
| 50 |
paths: {
|
| 51 |
-
'
|
| 52 |
-
'
|
| 53 |
operationId: 'train'
|
| 54 |
}
|
| 55 |
},
|
| 56 |
-
'
|
| 57 |
-
'
|
| 58 |
operationId: 'temperature',
|
| 59 |
parameters: [
|
| 60 |
{name: 'value',
|
|
@@ -63,8 +63,8 @@ Oid.customize('oid:rest', {
|
|
| 63 |
]
|
| 64 |
}
|
| 65 |
},
|
| 66 |
-
'
|
| 67 |
-
'
|
| 68 |
operationId: 'pressure',
|
| 69 |
parameters: [
|
| 70 |
{name: 'value',
|
|
|
|
| 6 |
api: {
|
| 7 |
oas: {
|
| 8 |
paths: {
|
| 9 |
+
'https://santanche-factory-ml.hf.space/train?train_path={train_path}&test_path={test_path}': {
|
| 10 |
'post': {
|
| 11 |
operationId: 'train',
|
| 12 |
parameters: [
|
|
|
|
| 19 |
]
|
| 20 |
}
|
| 21 |
},
|
| 22 |
+
'https://santanche-factory-ml.hf.space/predict?radius_mean={radius_mean}&texture_mean={texture_mean}&symmetry_mean={symmetry_mean}&fractal_dimension_mean={fractal_dimension_mean}': {
|
| 23 |
'get': {
|
| 24 |
operationId: 'predict',
|
| 25 |
parameters: [
|
|
|
|
| 48 |
api: {
|
| 49 |
oas: {
|
| 50 |
paths: {
|
| 51 |
+
'https://santanche-factory-ml.hf.space/train': {
|
| 52 |
+
'post': {
|
| 53 |
operationId: 'train'
|
| 54 |
}
|
| 55 |
},
|
| 56 |
+
'https://santanche-factory-ml.hf.space/inform_temperature?value={value}': {
|
| 57 |
+
'post': {
|
| 58 |
operationId: 'temperature',
|
| 59 |
parameters: [
|
| 60 |
{name: 'value',
|
|
|
|
| 63 |
]
|
| 64 |
}
|
| 65 |
},
|
| 66 |
+
'https://santanche-factory-ml.hf.space/inform_pressure?value={value}': {
|
| 67 |
+
'post': {
|
| 68 |
operationId: 'pressure',
|
| 69 |
parameters: [
|
| 70 |
{name: 'value',
|
app/static/gallery/factory-ai.html
CHANGED
|
@@ -14,7 +14,7 @@
|
|
| 14 |
<div style="width: 100%; height: 35%; background-color: grey; text-align: center">
|
| 15 |
<div style="font-size: larger; font-weight: bold;">Control Panel</div>
|
| 16 |
<span id="alert" style="width: 20%; display: inline-block; vertical-align: middle">
|
| 17 |
-
<state-pane-oid initial="N"
|
| 18 |
<image-oid id="N" source="assets:images/light-green.svg"></image-oid>
|
| 19 |
<image-oid id="P" source="assets:images/light-red.svg"></image-oid>
|
| 20 |
</state-pane-oid>
|
|
|
|
| 14 |
<div style="width: 100%; height: 35%; background-color: grey; text-align: center">
|
| 15 |
<div style="font-size: larger; font-weight: bold;">Control Panel</div>
|
| 16 |
<span id="alert" style="width: 20%; display: inline-block; vertical-align: middle">
|
| 17 |
+
<state-pane-oid initial="N">
|
| 18 |
<image-oid id="N" source="assets:images/light-green.svg"></image-oid>
|
| 19 |
<image-oid id="P" source="assets:images/light-red.svg"></image-oid>
|
| 20 |
</state-pane-oid>
|