Spaces:
Runtime error
Runtime error
feat: enhance FastAPI application with detailed metadata, improved UI, and comprehensive README updates
Browse files- Mental_Health_API.postman_collection.json +254 -0
- README.md +119 -0
- app.py +35 -2
- templates/index.html +924 -193
Mental_Health_API.postman_collection.json
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"info": {
|
| 3 |
+
"_postman_id": "b4f9208a-9323-4ea2-8df4-3b0335d66cf5",
|
| 4 |
+
"name": "Mental Health API",
|
| 5 |
+
"description": "Collection for testing the Mental Health Disorder Prediction API",
|
| 6 |
+
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
| 7 |
+
},
|
| 8 |
+
"item": [
|
| 9 |
+
{
|
| 10 |
+
"name": "Health Check",
|
| 11 |
+
"request": {
|
| 12 |
+
"method": "GET",
|
| 13 |
+
"header": [],
|
| 14 |
+
"url": {
|
| 15 |
+
"raw": "{{base_url}}/health",
|
| 16 |
+
"host": [
|
| 17 |
+
"{{base_url}}"
|
| 18 |
+
],
|
| 19 |
+
"path": [
|
| 20 |
+
"health"
|
| 21 |
+
]
|
| 22 |
+
},
|
| 23 |
+
"description": "Check if the API is up and running"
|
| 24 |
+
},
|
| 25 |
+
"response": []
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"name": "API Information",
|
| 29 |
+
"request": {
|
| 30 |
+
"method": "GET",
|
| 31 |
+
"header": [],
|
| 32 |
+
"url": {
|
| 33 |
+
"raw": "{{base_url}}/api",
|
| 34 |
+
"host": [
|
| 35 |
+
"{{base_url}}"
|
| 36 |
+
],
|
| 37 |
+
"path": [
|
| 38 |
+
"api"
|
| 39 |
+
]
|
| 40 |
+
},
|
| 41 |
+
"description": "Get information about the API endpoints"
|
| 42 |
+
},
|
| 43 |
+
"response": []
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"name": "Get HTML Form",
|
| 47 |
+
"request": {
|
| 48 |
+
"method": "GET",
|
| 49 |
+
"header": [],
|
| 50 |
+
"url": {
|
| 51 |
+
"raw": "{{base_url}}/",
|
| 52 |
+
"host": [
|
| 53 |
+
"{{base_url}}"
|
| 54 |
+
],
|
| 55 |
+
"path": [
|
| 56 |
+
""
|
| 57 |
+
]
|
| 58 |
+
},
|
| 59 |
+
"description": "Get the HTML form for mental health assessment"
|
| 60 |
+
},
|
| 61 |
+
"response": []
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"name": "Predict Mental Health Disorder",
|
| 65 |
+
"request": {
|
| 66 |
+
"method": "POST",
|
| 67 |
+
"header": [],
|
| 68 |
+
"body": {
|
| 69 |
+
"mode": "formdata",
|
| 70 |
+
"formdata": [
|
| 71 |
+
{
|
| 72 |
+
"key": "age",
|
| 73 |
+
"value": "25",
|
| 74 |
+
"type": "text"
|
| 75 |
+
},
|
| 76 |
+
{
|
| 77 |
+
"key": "feeling_nervous",
|
| 78 |
+
"value": "Ya",
|
| 79 |
+
"type": "text"
|
| 80 |
+
},
|
| 81 |
+
{
|
| 82 |
+
"key": "panic",
|
| 83 |
+
"value": "Ya",
|
| 84 |
+
"type": "text"
|
| 85 |
+
},
|
| 86 |
+
{
|
| 87 |
+
"key": "breathing_rapidly",
|
| 88 |
+
"value": "Ya",
|
| 89 |
+
"type": "text"
|
| 90 |
+
},
|
| 91 |
+
{
|
| 92 |
+
"key": "sweating",
|
| 93 |
+
"value": "Tidak",
|
| 94 |
+
"type": "text"
|
| 95 |
+
},
|
| 96 |
+
{
|
| 97 |
+
"key": "trouble_in_concentration",
|
| 98 |
+
"value": "Ya",
|
| 99 |
+
"type": "text"
|
| 100 |
+
},
|
| 101 |
+
{
|
| 102 |
+
"key": "having_trouble_in_sleeping",
|
| 103 |
+
"value": "Ya",
|
| 104 |
+
"type": "text"
|
| 105 |
+
},
|
| 106 |
+
{
|
| 107 |
+
"key": "having_trouble_with_work",
|
| 108 |
+
"value": "Ya",
|
| 109 |
+
"type": "text"
|
| 110 |
+
},
|
| 111 |
+
{
|
| 112 |
+
"key": "hopelessness",
|
| 113 |
+
"value": "Ya",
|
| 114 |
+
"type": "text"
|
| 115 |
+
},
|
| 116 |
+
{
|
| 117 |
+
"key": "anger",
|
| 118 |
+
"value": "Tidak",
|
| 119 |
+
"type": "text"
|
| 120 |
+
},
|
| 121 |
+
{
|
| 122 |
+
"key": "over_react",
|
| 123 |
+
"value": "Tidak",
|
| 124 |
+
"type": "text"
|
| 125 |
+
},
|
| 126 |
+
{
|
| 127 |
+
"key": "change_in_eating",
|
| 128 |
+
"value": "Tidak",
|
| 129 |
+
"type": "text"
|
| 130 |
+
},
|
| 131 |
+
{
|
| 132 |
+
"key": "suicidal_thought",
|
| 133 |
+
"value": "Tidak",
|
| 134 |
+
"type": "text"
|
| 135 |
+
},
|
| 136 |
+
{
|
| 137 |
+
"key": "feeling_tired",
|
| 138 |
+
"value": "Ya",
|
| 139 |
+
"type": "text"
|
| 140 |
+
},
|
| 141 |
+
{
|
| 142 |
+
"key": "close_friend",
|
| 143 |
+
"value": "Tidak",
|
| 144 |
+
"type": "text"
|
| 145 |
+
},
|
| 146 |
+
{
|
| 147 |
+
"key": "social_media_addiction",
|
| 148 |
+
"value": "Ya",
|
| 149 |
+
"type": "text"
|
| 150 |
+
},
|
| 151 |
+
{
|
| 152 |
+
"key": "weight_gain",
|
| 153 |
+
"value": "Tidak",
|
| 154 |
+
"type": "text"
|
| 155 |
+
},
|
| 156 |
+
{
|
| 157 |
+
"key": "introvert",
|
| 158 |
+
"value": "Ya",
|
| 159 |
+
"type": "text"
|
| 160 |
+
},
|
| 161 |
+
{
|
| 162 |
+
"key": "popping_up_stressful_memory",
|
| 163 |
+
"value": "Tidak",
|
| 164 |
+
"type": "text"
|
| 165 |
+
},
|
| 166 |
+
{
|
| 167 |
+
"key": "having_nightmares",
|
| 168 |
+
"value": "Tidak",
|
| 169 |
+
"type": "text"
|
| 170 |
+
},
|
| 171 |
+
{
|
| 172 |
+
"key": "avoids_people_or_activities",
|
| 173 |
+
"value": "Ya",
|
| 174 |
+
"type": "text"
|
| 175 |
+
},
|
| 176 |
+
{
|
| 177 |
+
"key": "feeling_negative",
|
| 178 |
+
"value": "Ya",
|
| 179 |
+
"type": "text"
|
| 180 |
+
},
|
| 181 |
+
{
|
| 182 |
+
"key": "trouble_concentrating",
|
| 183 |
+
"value": "Ya",
|
| 184 |
+
"type": "text"
|
| 185 |
+
},
|
| 186 |
+
{
|
| 187 |
+
"key": "blaming_yourself",
|
| 188 |
+
"value": "Ya",
|
| 189 |
+
"type": "text"
|
| 190 |
+
},
|
| 191 |
+
{
|
| 192 |
+
"key": "hallucinations",
|
| 193 |
+
"value": "Tidak",
|
| 194 |
+
"type": "text"
|
| 195 |
+
},
|
| 196 |
+
{
|
| 197 |
+
"key": "repetitive_behaviour",
|
| 198 |
+
"value": "Tidak",
|
| 199 |
+
"type": "text"
|
| 200 |
+
},
|
| 201 |
+
{
|
| 202 |
+
"key": "seasonally",
|
| 203 |
+
"value": "Tidak",
|
| 204 |
+
"type": "text"
|
| 205 |
+
},
|
| 206 |
+
{
|
| 207 |
+
"key": "increased_energy",
|
| 208 |
+
"value": "Tidak",
|
| 209 |
+
"type": "text"
|
| 210 |
+
}
|
| 211 |
+
]
|
| 212 |
+
},
|
| 213 |
+
"url": {
|
| 214 |
+
"raw": "{{base_url}}/",
|
| 215 |
+
"host": [
|
| 216 |
+
"{{base_url}}"
|
| 217 |
+
],
|
| 218 |
+
"path": [
|
| 219 |
+
""
|
| 220 |
+
]
|
| 221 |
+
},
|
| 222 |
+
"description": "Submit form data to get a mental health disorder prediction"
|
| 223 |
+
},
|
| 224 |
+
"response": []
|
| 225 |
+
}
|
| 226 |
+
],
|
| 227 |
+
"event": [
|
| 228 |
+
{
|
| 229 |
+
"listen": "prerequest",
|
| 230 |
+
"script": {
|
| 231 |
+
"type": "text/javascript",
|
| 232 |
+
"exec": [
|
| 233 |
+
""
|
| 234 |
+
]
|
| 235 |
+
}
|
| 236 |
+
},
|
| 237 |
+
{
|
| 238 |
+
"listen": "test",
|
| 239 |
+
"script": {
|
| 240 |
+
"type": "text/javascript",
|
| 241 |
+
"exec": [
|
| 242 |
+
""
|
| 243 |
+
]
|
| 244 |
+
}
|
| 245 |
+
}
|
| 246 |
+
],
|
| 247 |
+
"variable": [
|
| 248 |
+
{
|
| 249 |
+
"key": "base_url",
|
| 250 |
+
"value": "http://localhost:7860",
|
| 251 |
+
"type": "string"
|
| 252 |
+
}
|
| 253 |
+
]
|
| 254 |
+
}
|
README.md
CHANGED
|
@@ -12,6 +12,8 @@ license: apache-2.0
|
|
| 12 |
|
| 13 |
This repository contains a FastAPI application that predicts mental health disorders based on user input. The application utilizes a TensorFlow model to provide predictions.
|
| 14 |
|
|
|
|
|
|
|
| 15 |
## Features
|
| 16 |
|
| 17 |
- Mental health disorder prediction based on questionnaire responses
|
|
@@ -65,6 +67,123 @@ The server will start, and you can access:
|
|
| 65 |
| `/health` | GET | API health check |
|
| 66 |
| `/api` | GET | API information |
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
## Docker Deployment
|
| 69 |
|
| 70 |
Build and run the Docker image:
|
|
|
|
| 12 |
|
| 13 |
This repository contains a FastAPI application that predicts mental health disorders based on user input. The application utilizes a TensorFlow model to provide predictions.
|
| 14 |
|
| 15 |
+
> **Note**: This application is a fork of [Mentalys-App/tabular_ml](https://github.com/Mentalys-App/tabular_ml) and was originally created by [I Gede Widnyana (@GdWidnyana)](https://github.com/GdWidnyana).
|
| 16 |
+
|
| 17 |
## Features
|
| 18 |
|
| 19 |
- Mental health disorder prediction based on questionnaire responses
|
|
|
|
| 67 |
| `/health` | GET | API health check |
|
| 68 |
| `/api` | GET | API information |
|
| 69 |
|
| 70 |
+
## API Usage Examples for Postman
|
| 71 |
+
|
| 72 |
+
### Health Check
|
| 73 |
+
|
| 74 |
+
```
|
| 75 |
+
GET /health
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
Example response:
|
| 79 |
+
```json
|
| 80 |
+
{
|
| 81 |
+
"status": "ok"
|
| 82 |
+
}
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
### API Information
|
| 86 |
+
|
| 87 |
+
```
|
| 88 |
+
GET /api
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
Example response:
|
| 92 |
+
```json
|
| 93 |
+
{
|
| 94 |
+
"api_name": "Mental Health Disorder Prediction API",
|
| 95 |
+
"version": "1.0",
|
| 96 |
+
"endpoints": [
|
| 97 |
+
{"path": "/", "method": "GET", "description": "HTML form interface"},
|
| 98 |
+
{"path": "/", "method": "POST", "description": "Prediction endpoint (form data)"},
|
| 99 |
+
{"path": "/health", "method": "GET", "description": "API health check"},
|
| 100 |
+
{"path": "/api", "method": "GET", "description": "API information"}
|
| 101 |
+
]
|
| 102 |
+
}
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
### Prediction Request
|
| 106 |
+
|
| 107 |
+
**Endpoint:** `POST /`
|
| 108 |
+
|
| 109 |
+
**Headers:**
|
| 110 |
+
- Content-Type: multipart/form-data
|
| 111 |
+
|
| 112 |
+
**Form Data Parameters:**
|
| 113 |
+
```
|
| 114 |
+
age: 25
|
| 115 |
+
feeling_nervous: Ya
|
| 116 |
+
panic: Ya
|
| 117 |
+
breathing_rapidly: Ya
|
| 118 |
+
sweating: Tidak
|
| 119 |
+
trouble_in_concentration: Ya
|
| 120 |
+
having_trouble_in_sleeping: Ya
|
| 121 |
+
having_trouble_with_work: Ya
|
| 122 |
+
hopelessness: Ya
|
| 123 |
+
anger: Tidak
|
| 124 |
+
over_react: Tidak
|
| 125 |
+
change_in_eating: Tidak
|
| 126 |
+
suicidal_thought: Tidak
|
| 127 |
+
feeling_tired: Ya
|
| 128 |
+
close_friend: Tidak
|
| 129 |
+
social_media_addiction: Ya
|
| 130 |
+
weight_gain: Tidak
|
| 131 |
+
introvert: Ya
|
| 132 |
+
popping_up_stressful_memory: Tidak
|
| 133 |
+
having_nightmares: Tidak
|
| 134 |
+
avoids_people_or_activities: Ya
|
| 135 |
+
feeling_negative: Ya
|
| 136 |
+
trouble_concentrating: Ya
|
| 137 |
+
blaming_yourself: Ya
|
| 138 |
+
hallucinations: Tidak
|
| 139 |
+
repetitive_behaviour: Tidak
|
| 140 |
+
seasonally: Tidak
|
| 141 |
+
increased_energy: Tidak
|
| 142 |
+
```
|
| 143 |
+
|
| 144 |
+
**Example Response:**
|
| 145 |
+
```json
|
| 146 |
+
{
|
| 147 |
+
"result": "Hasil Diagnosa bahwa Anda mengalami Gangguan Kecemasan dengan tingkat kepercayaan 85.76%",
|
| 148 |
+
"prediction": "Gangguan Kecemasan",
|
| 149 |
+
"confidence": 85.76
|
| 150 |
+
}
|
| 151 |
+
```
|
| 152 |
+
|
| 153 |
+
## Curl Example
|
| 154 |
+
|
| 155 |
+
```bash
|
| 156 |
+
curl -X POST 'https://mentalys-app-quiz-classification.hf.space/' \
|
| 157 |
+
-F 'age=25' \
|
| 158 |
+
-F 'feeling_nervous=Ya' \
|
| 159 |
+
-F 'panic=Ya' \
|
| 160 |
+
-F 'breathing_rapidly=Ya' \
|
| 161 |
+
-F 'sweating=Tidak' \
|
| 162 |
+
-F 'trouble_in_concentration=Ya' \
|
| 163 |
+
-F 'having_trouble_in_sleeping=Ya' \
|
| 164 |
+
-F 'having_trouble_with_work=Ya' \
|
| 165 |
+
-F 'hopelessness=Ya' \
|
| 166 |
+
-F 'anger=Tidak' \
|
| 167 |
+
-F 'over_react=Tidak' \
|
| 168 |
+
-F 'change_in_eating=Tidak' \
|
| 169 |
+
-F 'suicidal_thought=Tidak' \
|
| 170 |
+
-F 'feeling_tired=Ya' \
|
| 171 |
+
-F 'close_friend=Tidak' \
|
| 172 |
+
-F 'social_media_addiction=Ya' \
|
| 173 |
+
-F 'weight_gain=Tidak' \
|
| 174 |
+
-F 'introvert=Ya' \
|
| 175 |
+
-F 'popping_up_stressful_memory=Tidak' \
|
| 176 |
+
-F 'having_nightmares=Tidak' \
|
| 177 |
+
-F 'avoids_people_or_activities=Ya' \
|
| 178 |
+
-F 'feeling_negative=Ya' \
|
| 179 |
+
-F 'trouble_concentrating=Ya' \
|
| 180 |
+
-F 'blaming_yourself=Ya' \
|
| 181 |
+
-F 'hallucinations=Tidak' \
|
| 182 |
+
-F 'repetitive_behaviour=Tidak' \
|
| 183 |
+
-F 'seasonally=Tidak' \
|
| 184 |
+
-F 'increased_energy=Tidak'
|
| 185 |
+
```
|
| 186 |
+
|
| 187 |
## Docker Deployment
|
| 188 |
|
| 189 |
Build and run the Docker image:
|
app.py
CHANGED
|
@@ -9,7 +9,21 @@ from typing import Optional
|
|
| 9 |
import os
|
| 10 |
from pathlib import Path
|
| 11 |
|
| 12 |
-
app = FastAPI(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# Set up templates directory
|
| 15 |
templates_path = Path("templates")
|
|
@@ -76,7 +90,21 @@ label_mapping = {
|
|
| 76 |
@app.get("/", response_class=HTMLResponse)
|
| 77 |
async def index(request: Request):
|
| 78 |
if templates_path.exists():
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
else:
|
| 81 |
return HTMLResponse(content="<h1>Template not found</h1>", status_code=404)
|
| 82 |
|
|
@@ -181,6 +209,11 @@ async def api_info():
|
|
| 181 |
return {
|
| 182 |
"api_name": "Mental Health Disorder Prediction API",
|
| 183 |
"version": "1.0",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
"endpoints": [
|
| 185 |
{"path": "/", "method": "GET", "description": "HTML form interface"},
|
| 186 |
{"path": "/", "method": "POST", "description": "Prediction endpoint (form data)"},
|
|
|
|
| 9 |
import os
|
| 10 |
from pathlib import Path
|
| 11 |
|
| 12 |
+
app = FastAPI(
|
| 13 |
+
title="Mental Health Disorder Prediction API",
|
| 14 |
+
description="API for predicting mental health disorders based on questionnaire responses. "
|
| 15 |
+
"This application is a fork of https://github.com/Mentalys-App/tabular_ml and was "
|
| 16 |
+
"originally created by I Gede Widnyana (https://github.com/GdWidnyana).",
|
| 17 |
+
version="1.0",
|
| 18 |
+
contact={
|
| 19 |
+
"name": "Mentalys App",
|
| 20 |
+
"url": "https://github.com/Mentalys-App",
|
| 21 |
+
},
|
| 22 |
+
license_info={
|
| 23 |
+
"name": "Apache 2.0",
|
| 24 |
+
"url": "https://www.apache.org/licenses/LICENSE-2.0.html",
|
| 25 |
+
}
|
| 26 |
+
)
|
| 27 |
|
| 28 |
# Set up templates directory
|
| 29 |
templates_path = Path("templates")
|
|
|
|
| 90 |
@app.get("/", response_class=HTMLResponse)
|
| 91 |
async def index(request: Request):
|
| 92 |
if templates_path.exists():
|
| 93 |
+
# Pass additional context data to the template
|
| 94 |
+
context = {
|
| 95 |
+
"request": request,
|
| 96 |
+
"result": "",
|
| 97 |
+
"app_info": {
|
| 98 |
+
"title": "Mental Health Disorder Prediction API",
|
| 99 |
+
"description": "This application predicts mental health disorders based on questionnaire responses.",
|
| 100 |
+
"author": "I Gede Widnyana (@GdWidnyana)",
|
| 101 |
+
"author_url": "https://github.com/GdWidnyana",
|
| 102 |
+
"original_repo": "https://github.com/Mentalys-App/tabular_ml",
|
| 103 |
+
"organization": "Mentalys App",
|
| 104 |
+
"organization_url": "https://github.com/Mentalys-App"
|
| 105 |
+
}
|
| 106 |
+
}
|
| 107 |
+
return templates.TemplateResponse("index.html", context)
|
| 108 |
else:
|
| 109 |
return HTMLResponse(content="<h1>Template not found</h1>", status_code=404)
|
| 110 |
|
|
|
|
| 209 |
return {
|
| 210 |
"api_name": "Mental Health Disorder Prediction API",
|
| 211 |
"version": "1.0",
|
| 212 |
+
"author": "I Gede Widnyana (@GdWidnyana)",
|
| 213 |
+
"author_url": "https://github.com/GdWidnyana",
|
| 214 |
+
"original_repo": "https://github.com/Mentalys-App/tabular_ml",
|
| 215 |
+
"organization": "Mentalys App",
|
| 216 |
+
"organization_url": "https://github.com/Mentalys-App",
|
| 217 |
"endpoints": [
|
| 218 |
{"path": "/", "method": "GET", "description": "HTML form interface"},
|
| 219 |
{"path": "/", "method": "POST", "description": "Prediction endpoint (form data)"},
|
templates/index.html
CHANGED
|
@@ -1,243 +1,974 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="id">
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="UTF-8">
|
| 5 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
<style>
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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 11 |
}
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
}
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
display: block;
|
| 19 |
}
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
}
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
padding: 10px 20px;
|
| 27 |
-
border: none;
|
| 28 |
-
cursor: pointer;
|
| 29 |
-
font-size: 16px;
|
| 30 |
}
|
| 31 |
-
|
| 32 |
-
|
|
|
|
| 33 |
}
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
font-weight: bold;
|
| 38 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
</style>
|
| 40 |
-
</head>
|
| 41 |
-
<body>
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
<
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
<input type="number" id="age" name="age" required min="0" max="150" placeholder="Masukkan usia Anda" /><br><br>
|
| 49 |
-
</div>
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
</div>
|
| 57 |
|
| 58 |
-
<div class="
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
<
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
-
|
| 65 |
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
|
| 202 |
-
|
| 203 |
-
<
|
| 204 |
-
|
| 205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
</div>
|
| 207 |
|
| 208 |
<!-- Submit Button -->
|
| 209 |
-
<button type="submit">Submit</button>
|
| 210 |
-
|
|
|
|
|
|
|
|
|
|
| 211 |
|
| 212 |
-
|
| 213 |
-
|
| 214 |
<h2>{{ result }}</h2>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
</div>
|
| 216 |
|
| 217 |
<script>
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
});
|
| 240 |
});
|
|
|
|
| 241 |
</script>
|
| 242 |
-
</body>
|
| 243 |
</html>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="id">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 6 |
+
<title>{{ app_info.title }}</title>
|
| 7 |
+
<link
|
| 8 |
+
href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap"
|
| 9 |
+
rel="stylesheet"
|
| 10 |
+
/>
|
| 11 |
<style>
|
| 12 |
+
:root {
|
| 13 |
+
--primary: #2c9c69;
|
| 14 |
+
--primary-dark: #218057;
|
| 15 |
+
--secondary: #f8f9fa;
|
| 16 |
+
--text: #333333;
|
| 17 |
+
--text-light: #6c757d;
|
| 18 |
+
--danger: #dc3545;
|
| 19 |
+
--success: #28a745;
|
| 20 |
+
--warning: #ffc107;
|
| 21 |
+
--info: #17a2b8;
|
| 22 |
+
--border: #dee2e6;
|
| 23 |
+
--shadow: rgba(0, 0, 0, 0.1);
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
* {
|
| 27 |
+
box-sizing: border-box;
|
| 28 |
+
margin: 0;
|
| 29 |
+
padding: 0;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
body {
|
| 33 |
+
font-family: "Poppins", sans-serif;
|
| 34 |
+
line-height: 1.6;
|
| 35 |
+
color: var(--text);
|
| 36 |
+
background-color: #f5f7fa;
|
| 37 |
+
margin: 0;
|
| 38 |
+
padding: 0;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
.container {
|
| 42 |
+
max-width: 1100px;
|
| 43 |
+
margin: 0 auto;
|
| 44 |
+
padding: 20px;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
header {
|
| 48 |
+
background: linear-gradient(
|
| 49 |
+
135deg,
|
| 50 |
+
var(--primary) 0%,
|
| 51 |
+
var(--primary-dark) 100%
|
| 52 |
+
);
|
| 53 |
+
color: white;
|
| 54 |
+
padding: 2rem 0;
|
| 55 |
+
margin-bottom: 2rem;
|
| 56 |
+
box-shadow: 0 4px 6px var(--shadow);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
header .container {
|
| 60 |
+
display: flex;
|
| 61 |
+
flex-direction: column;
|
| 62 |
+
align-items: center;
|
| 63 |
+
text-align: center;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
header h1 {
|
| 67 |
+
margin-bottom: 1rem;
|
| 68 |
+
font-weight: 600;
|
| 69 |
+
font-size: 2.5rem;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
header p {
|
| 73 |
+
max-width: 600px;
|
| 74 |
+
opacity: 0.9;
|
| 75 |
+
font-weight: 300;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
.card {
|
| 79 |
+
background-color: white;
|
| 80 |
+
border-radius: 8px;
|
| 81 |
+
box-shadow: 0 2px 10px var(--shadow);
|
| 82 |
+
margin-bottom: 2rem;
|
| 83 |
+
overflow: hidden;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
.card-header {
|
| 87 |
+
background-color: var(--secondary);
|
| 88 |
+
padding: 1rem 1.5rem;
|
| 89 |
+
border-bottom: 1px solid var(--border);
|
| 90 |
+
font-weight: 600;
|
| 91 |
+
font-size: 1.2rem;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
.card-body {
|
| 95 |
+
padding: 1.5rem;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
form {
|
| 99 |
+
display: flex;
|
| 100 |
+
flex-direction: column;
|
| 101 |
+
gap: 1.5rem;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
.form-group {
|
| 105 |
+
margin-bottom: 1rem;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
.question {
|
| 109 |
+
background-color: white;
|
| 110 |
+
padding: 1rem;
|
| 111 |
+
border-radius: 8px;
|
| 112 |
+
border: 1px solid var(--border);
|
| 113 |
+
transition: all 0.3s ease;
|
| 114 |
+
margin-bottom: 1rem;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
.question:hover {
|
| 118 |
+
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
|
| 119 |
+
transform: translateY(-2px);
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
label {
|
| 123 |
+
font-size: 1rem;
|
| 124 |
+
margin-bottom: 0.5rem;
|
| 125 |
+
display: block;
|
| 126 |
+
font-weight: 500;
|
| 127 |
+
color: var(--text);
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
.radio-group {
|
| 131 |
+
display: flex;
|
| 132 |
+
gap: 1.5rem;
|
| 133 |
+
margin-top: 0.5rem;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
.radio-option {
|
| 137 |
+
display: flex;
|
| 138 |
+
align-items: center;
|
| 139 |
+
cursor: pointer;
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
.radio-option input {
|
| 143 |
+
margin-right: 0.5rem;
|
| 144 |
+
}
|
| 145 |
+
|
| 146 |
+
input[type="number"] {
|
| 147 |
+
width: 100%;
|
| 148 |
+
padding: 0.75rem;
|
| 149 |
+
border: 1px solid var(--border);
|
| 150 |
+
border-radius: 4px;
|
| 151 |
+
font-size: 1rem;
|
| 152 |
+
font-family: inherit;
|
| 153 |
+
transition: border-color 0.3s;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
input[type="number"]:focus {
|
| 157 |
+
border-color: var(--primary);
|
| 158 |
+
outline: none;
|
| 159 |
+
box-shadow: 0 0 0 3px rgba(44, 156, 105, 0.2);
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
button {
|
| 163 |
+
background-color: var(--primary);
|
| 164 |
+
color: white;
|
| 165 |
+
padding: 12px 24px;
|
| 166 |
+
border: none;
|
| 167 |
+
border-radius: 4px;
|
| 168 |
+
cursor: pointer;
|
| 169 |
+
font-size: 1rem;
|
| 170 |
+
font-weight: 500;
|
| 171 |
+
transition: background-color 0.3s, transform 0.2s;
|
| 172 |
+
align-self: center;
|
| 173 |
+
margin-top: 1rem;
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
button:hover {
|
| 177 |
+
background-color: var(--primary-dark);
|
| 178 |
+
transform: translateY(-2px);
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
button:active {
|
| 182 |
+
transform: translateY(0);
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
.questions-container {
|
| 186 |
+
display: grid;
|
| 187 |
+
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
| 188 |
+
gap: 1rem;
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
.result {
|
| 192 |
+
margin-top: 2rem;
|
| 193 |
+
padding: 1.5rem;
|
| 194 |
+
border-radius: 8px;
|
| 195 |
+
background-color: #f8f9fa;
|
| 196 |
+
border: 1px solid var(--border);
|
| 197 |
+
text-align: center;
|
| 198 |
+
transition: all 0.5s ease;
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
.result.active {
|
| 202 |
+
background-color: #e8f4ff;
|
| 203 |
+
border-color: #9ecbff;
|
| 204 |
+
box-shadow: 0 0 20px rgba(0, 123, 255, 0.1);
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
.result h2 {
|
| 208 |
+
color: var(--primary);
|
| 209 |
+
margin-bottom: 0.5rem;
|
| 210 |
+
font-weight: 600;
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
.age-input {
|
| 214 |
+
max-width: 300px;
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
.attribution {
|
| 218 |
+
margin-top: 3rem;
|
| 219 |
+
padding: 1.5rem;
|
| 220 |
+
background-color: white;
|
| 221 |
+
border-radius: 8px;
|
| 222 |
+
border: 1px solid var(--border);
|
| 223 |
+
font-size: 0.9rem;
|
| 224 |
+
box-shadow: 0 2px 8px var(--shadow);
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
.attribution h3 {
|
| 228 |
+
color: var(--primary);
|
| 229 |
+
margin-bottom: 1rem;
|
| 230 |
+
font-weight: 600;
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
.attribution a {
|
| 234 |
+
color: var(--primary);
|
| 235 |
+
text-decoration: none;
|
| 236 |
+
font-weight: 500;
|
| 237 |
+
transition: color 0.2s;
|
| 238 |
+
}
|
| 239 |
+
|
| 240 |
+
.attribution a:hover {
|
| 241 |
+
color: var(--primary-dark);
|
| 242 |
+
text-decoration: underline;
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
footer {
|
| 246 |
+
margin-top: 3rem;
|
| 247 |
+
padding: 1.5rem 0;
|
| 248 |
+
border-top: 1px solid var(--border);
|
| 249 |
+
text-align: center;
|
| 250 |
+
font-size: 0.85rem;
|
| 251 |
+
color: var(--text-light);
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
/* Loading spinner */
|
| 255 |
+
.spinner {
|
| 256 |
+
display: none;
|
| 257 |
+
width: 40px;
|
| 258 |
+
height: 40px;
|
| 259 |
+
margin: 20px auto;
|
| 260 |
+
border: 4px solid rgba(0, 0, 0, 0.1);
|
| 261 |
+
border-left-color: var(--primary);
|
| 262 |
+
border-radius: 50%;
|
| 263 |
+
animation: spin 1s linear infinite;
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
@keyframes spin {
|
| 267 |
+
to {
|
| 268 |
+
transform: rotate(360deg);
|
| 269 |
}
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
/* Response Animation */
|
| 273 |
+
@keyframes fadeIn {
|
| 274 |
+
from {
|
| 275 |
+
opacity: 0;
|
| 276 |
+
transform: translateY(20px);
|
| 277 |
}
|
| 278 |
+
to {
|
| 279 |
+
opacity: 1;
|
| 280 |
+
transform: translateY(0);
|
|
|
|
| 281 |
}
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
.fade-in {
|
| 285 |
+
animation: fadeIn 0.5s ease-out;
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
/* Responsive Design */
|
| 289 |
+
@media (max-width: 768px) {
|
| 290 |
+
.questions-container {
|
| 291 |
+
grid-template-columns: 1fr;
|
| 292 |
}
|
| 293 |
+
|
| 294 |
+
header h1 {
|
| 295 |
+
font-size: 2rem;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
}
|
| 297 |
+
|
| 298 |
+
.card-header {
|
| 299 |
+
padding: 1rem;
|
| 300 |
}
|
| 301 |
+
|
| 302 |
+
.card-body {
|
| 303 |
+
padding: 1rem;
|
|
|
|
| 304 |
}
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
/* Section headers */
|
| 308 |
+
.section-header {
|
| 309 |
+
margin: 2rem 0 1rem 0;
|
| 310 |
+
padding-bottom: 0.5rem;
|
| 311 |
+
border-bottom: 2px solid var(--primary);
|
| 312 |
+
color: var(--primary-dark);
|
| 313 |
+
font-weight: 600;
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
/* Age input styles */
|
| 317 |
+
.age-container {
|
| 318 |
+
margin-bottom: 2rem;
|
| 319 |
+
}
|
| 320 |
</style>
|
| 321 |
+
</head>
|
| 322 |
+
<body>
|
| 323 |
+
<header>
|
| 324 |
+
<div class="container">
|
| 325 |
+
<h1>Prediksi Gangguan Mental</h1>
|
| 326 |
+
<p>{{ app_info.description }}</p>
|
| 327 |
+
</div>
|
| 328 |
+
</header>
|
|
|
|
|
|
|
| 329 |
|
| 330 |
+
<div class="container">
|
| 331 |
+
<form method="POST" id="prediction-form">
|
| 332 |
+
<div class="card">
|
| 333 |
+
<div class="card-header">Informasi Dasar</div>
|
| 334 |
+
<div class="card-body">
|
| 335 |
+
<div class="age-container">
|
| 336 |
+
<label for="age">Berapa usia Anda?</label>
|
| 337 |
+
<input
|
| 338 |
+
type="number"
|
| 339 |
+
id="age"
|
| 340 |
+
name="age"
|
| 341 |
+
class="age-input"
|
| 342 |
+
required
|
| 343 |
+
min="0"
|
| 344 |
+
max="150"
|
| 345 |
+
placeholder="Masukkan usia Anda"
|
| 346 |
+
/>
|
| 347 |
+
</div>
|
| 348 |
+
</div>
|
| 349 |
</div>
|
| 350 |
|
| 351 |
+
<div class="card">
|
| 352 |
+
<div class="card-header">Kuesioner Kesehatan Mental</div>
|
| 353 |
+
<div class="card-body">
|
| 354 |
+
<p class="section-header">Emosi dan Perasaan</p>
|
| 355 |
+
<div class="questions-container">
|
| 356 |
+
<div class="question">
|
| 357 |
+
<label>Apakah Anda merasa cemas?</label>
|
| 358 |
+
<div class="radio-group">
|
| 359 |
+
<label class="radio-option"
|
| 360 |
+
><input type="radio" name="feeling_nervous" value="Ya" />
|
| 361 |
+
Ya</label
|
| 362 |
+
>
|
| 363 |
+
<label class="radio-option"
|
| 364 |
+
><input
|
| 365 |
+
type="radio"
|
| 366 |
+
name="feeling_nervous"
|
| 367 |
+
value="Tidak"
|
| 368 |
+
checked
|
| 369 |
+
/>
|
| 370 |
+
Tidak</label
|
| 371 |
+
>
|
| 372 |
+
</div>
|
| 373 |
+
</div>
|
| 374 |
|
| 375 |
+
<div class="question">
|
| 376 |
+
<label>Apakah Anda mengalami panik?</label>
|
| 377 |
+
<div class="radio-group">
|
| 378 |
+
<label class="radio-option"
|
| 379 |
+
><input type="radio" name="panic" value="Ya" /> Ya</label
|
| 380 |
+
>
|
| 381 |
+
<label class="radio-option"
|
| 382 |
+
><input type="radio" name="panic" value="Tidak" checked />
|
| 383 |
+
Tidak</label
|
| 384 |
+
>
|
| 385 |
+
</div>
|
| 386 |
+
</div>
|
| 387 |
|
| 388 |
+
<div class="question">
|
| 389 |
+
<label>Apakah Anda merasa putus asa?</label>
|
| 390 |
+
<div class="radio-group">
|
| 391 |
+
<label class="radio-option"
|
| 392 |
+
><input type="radio" name="hopelessness" value="Ya" />
|
| 393 |
+
Ya</label
|
| 394 |
+
>
|
| 395 |
+
<label class="radio-option"
|
| 396 |
+
><input
|
| 397 |
+
type="radio"
|
| 398 |
+
name="hopelessness"
|
| 399 |
+
value="Tidak"
|
| 400 |
+
checked
|
| 401 |
+
/>
|
| 402 |
+
Tidak</label
|
| 403 |
+
>
|
| 404 |
+
</div>
|
| 405 |
+
</div>
|
| 406 |
|
| 407 |
+
<div class="question">
|
| 408 |
+
<label>Apakah Anda sering merasa marah?</label>
|
| 409 |
+
<div class="radio-group">
|
| 410 |
+
<label class="radio-option"
|
| 411 |
+
><input type="radio" name="anger" value="Ya" /> Ya</label
|
| 412 |
+
>
|
| 413 |
+
<label class="radio-option"
|
| 414 |
+
><input type="radio" name="anger" value="Tidak" checked />
|
| 415 |
+
Tidak</label
|
| 416 |
+
>
|
| 417 |
+
</div>
|
| 418 |
+
</div>
|
| 419 |
|
| 420 |
+
<div class="question">
|
| 421 |
+
<label>Apakah Anda sering merasa negatif?</label>
|
| 422 |
+
<div class="radio-group">
|
| 423 |
+
<label class="radio-option"
|
| 424 |
+
><input type="radio" name="feeling_negative" value="Ya" />
|
| 425 |
+
Ya</label
|
| 426 |
+
>
|
| 427 |
+
<label class="radio-option"
|
| 428 |
+
><input
|
| 429 |
+
type="radio"
|
| 430 |
+
name="feeling_negative"
|
| 431 |
+
value="Tidak"
|
| 432 |
+
checked
|
| 433 |
+
/>
|
| 434 |
+
Tidak</label
|
| 435 |
+
>
|
| 436 |
+
</div>
|
| 437 |
+
</div>
|
| 438 |
|
| 439 |
+
<div class="question">
|
| 440 |
+
<label>Apakah Anda sering menyalahkan diri sendiri?</label>
|
| 441 |
+
<div class="radio-group">
|
| 442 |
+
<label class="radio-option"
|
| 443 |
+
><input type="radio" name="blaming_yourself" value="Ya" />
|
| 444 |
+
Ya</label
|
| 445 |
+
>
|
| 446 |
+
<label class="radio-option"
|
| 447 |
+
><input
|
| 448 |
+
type="radio"
|
| 449 |
+
name="blaming_yourself"
|
| 450 |
+
value="Tidak"
|
| 451 |
+
checked
|
| 452 |
+
/>
|
| 453 |
+
Tidak</label
|
| 454 |
+
>
|
| 455 |
+
</div>
|
| 456 |
+
</div>
|
| 457 |
+
</div>
|
| 458 |
|
| 459 |
+
<p class="section-header">Gejala Fisik</p>
|
| 460 |
+
<div class="questions-container">
|
| 461 |
+
<div class="question">
|
| 462 |
+
<label>Apakah Anda bernapas cepat?</label>
|
| 463 |
+
<div class="radio-group">
|
| 464 |
+
<label class="radio-option"
|
| 465 |
+
><input type="radio" name="breathing_rapidly" value="Ya" />
|
| 466 |
+
Ya</label
|
| 467 |
+
>
|
| 468 |
+
<label class="radio-option"
|
| 469 |
+
><input
|
| 470 |
+
type="radio"
|
| 471 |
+
name="breathing_rapidly"
|
| 472 |
+
value="Tidak"
|
| 473 |
+
checked
|
| 474 |
+
/>
|
| 475 |
+
Tidak</label
|
| 476 |
+
>
|
| 477 |
+
</div>
|
| 478 |
+
</div>
|
| 479 |
|
| 480 |
+
<div class="question">
|
| 481 |
+
<label>Apakah Anda berkeringat?</label>
|
| 482 |
+
<div class="radio-group">
|
| 483 |
+
<label class="radio-option"
|
| 484 |
+
><input type="radio" name="sweating" value="Ya" /> Ya</label
|
| 485 |
+
>
|
| 486 |
+
<label class="radio-option"
|
| 487 |
+
><input
|
| 488 |
+
type="radio"
|
| 489 |
+
name="sweating"
|
| 490 |
+
value="Tidak"
|
| 491 |
+
checked
|
| 492 |
+
/>
|
| 493 |
+
Tidak</label
|
| 494 |
+
>
|
| 495 |
+
</div>
|
| 496 |
+
</div>
|
| 497 |
|
| 498 |
+
<div class="question">
|
| 499 |
+
<label>Apakah Anda sering merasa lelah?</label>
|
| 500 |
+
<div class="radio-group">
|
| 501 |
+
<label class="radio-option"
|
| 502 |
+
><input type="radio" name="feeling_tired" value="Ya" />
|
| 503 |
+
Ya</label
|
| 504 |
+
>
|
| 505 |
+
<label class="radio-option"
|
| 506 |
+
><input
|
| 507 |
+
type="radio"
|
| 508 |
+
name="feeling_tired"
|
| 509 |
+
value="Tidak"
|
| 510 |
+
checked
|
| 511 |
+
/>
|
| 512 |
+
Tidak</label
|
| 513 |
+
>
|
| 514 |
+
</div>
|
| 515 |
+
</div>
|
| 516 |
|
| 517 |
+
<div class="question">
|
| 518 |
+
<label>Apakah Anda mengalami kenaikan berat badan?</label>
|
| 519 |
+
<div class="radio-group">
|
| 520 |
+
<label class="radio-option"
|
| 521 |
+
><input type="radio" name="weight_gain" value="Ya" />
|
| 522 |
+
Ya</label
|
| 523 |
+
>
|
| 524 |
+
<label class="radio-option"
|
| 525 |
+
><input
|
| 526 |
+
type="radio"
|
| 527 |
+
name="weight_gain"
|
| 528 |
+
value="Tidak"
|
| 529 |
+
checked
|
| 530 |
+
/>
|
| 531 |
+
Tidak</label
|
| 532 |
+
>
|
| 533 |
+
</div>
|
| 534 |
+
</div>
|
| 535 |
|
| 536 |
+
<div class="question">
|
| 537 |
+
<label>Apakah Anda merasa lebih berenergi dari biasanya?</label>
|
| 538 |
+
<div class="radio-group">
|
| 539 |
+
<label class="radio-option"
|
| 540 |
+
><input type="radio" name="increased_energy" value="Ya" />
|
| 541 |
+
Ya</label
|
| 542 |
+
>
|
| 543 |
+
<label class="radio-option"
|
| 544 |
+
><input
|
| 545 |
+
type="radio"
|
| 546 |
+
name="increased_energy"
|
| 547 |
+
value="Tidak"
|
| 548 |
+
checked
|
| 549 |
+
/>
|
| 550 |
+
Tidak</label
|
| 551 |
+
>
|
| 552 |
+
</div>
|
| 553 |
+
</div>
|
| 554 |
+
</div>
|
| 555 |
|
| 556 |
+
<p class="section-header">Pola Tidur dan Konsentrasi</p>
|
| 557 |
+
<div class="questions-container">
|
| 558 |
+
<div class="question">
|
| 559 |
+
<label>Apakah Anda mengalami kesulitan berkonsentrasi?</label>
|
| 560 |
+
<div class="radio-group">
|
| 561 |
+
<label class="radio-option"
|
| 562 |
+
><input
|
| 563 |
+
type="radio"
|
| 564 |
+
name="trouble_in_concentration"
|
| 565 |
+
value="Ya"
|
| 566 |
+
/>
|
| 567 |
+
Ya</label
|
| 568 |
+
>
|
| 569 |
+
<label class="radio-option"
|
| 570 |
+
><input
|
| 571 |
+
type="radio"
|
| 572 |
+
name="trouble_in_concentration"
|
| 573 |
+
value="Tidak"
|
| 574 |
+
checked
|
| 575 |
+
/>
|
| 576 |
+
Tidak</label
|
| 577 |
+
>
|
| 578 |
+
</div>
|
| 579 |
+
</div>
|
| 580 |
|
| 581 |
+
<div class="question">
|
| 582 |
+
<label>Apakah Anda mengalami kesulitan tidur?</label>
|
| 583 |
+
<div class="radio-group">
|
| 584 |
+
<label class="radio-option"
|
| 585 |
+
><input
|
| 586 |
+
type="radio"
|
| 587 |
+
name="having_trouble_in_sleeping"
|
| 588 |
+
value="Ya"
|
| 589 |
+
/>
|
| 590 |
+
Ya</label
|
| 591 |
+
>
|
| 592 |
+
<label class="radio-option"
|
| 593 |
+
><input
|
| 594 |
+
type="radio"
|
| 595 |
+
name="having_trouble_in_sleeping"
|
| 596 |
+
value="Tidak"
|
| 597 |
+
checked
|
| 598 |
+
/>
|
| 599 |
+
Tidak</label
|
| 600 |
+
>
|
| 601 |
+
</div>
|
| 602 |
+
</div>
|
| 603 |
|
| 604 |
+
<div class="question">
|
| 605 |
+
<label>Apakah Anda sering mengalami mimpi buruk?</label>
|
| 606 |
+
<div class="radio-group">
|
| 607 |
+
<label class="radio-option"
|
| 608 |
+
><input type="radio" name="having_nightmares" value="Ya" />
|
| 609 |
+
Ya</label
|
| 610 |
+
>
|
| 611 |
+
<label class="radio-option"
|
| 612 |
+
><input
|
| 613 |
+
type="radio"
|
| 614 |
+
name="having_nightmares"
|
| 615 |
+
value="Tidak"
|
| 616 |
+
checked
|
| 617 |
+
/>
|
| 618 |
+
Tidak</label
|
| 619 |
+
>
|
| 620 |
+
</div>
|
| 621 |
+
</div>
|
| 622 |
|
| 623 |
+
<div class="question">
|
| 624 |
+
<label>Apakah Anda mengalami kesulitan dalam bekerja?</label>
|
| 625 |
+
<div class="radio-group">
|
| 626 |
+
<label class="radio-option"
|
| 627 |
+
><input
|
| 628 |
+
type="radio"
|
| 629 |
+
name="having_trouble_with_work"
|
| 630 |
+
value="Ya"
|
| 631 |
+
/>
|
| 632 |
+
Ya</label
|
| 633 |
+
>
|
| 634 |
+
<label class="radio-option"
|
| 635 |
+
><input
|
| 636 |
+
type="radio"
|
| 637 |
+
name="having_trouble_with_work"
|
| 638 |
+
value="Tidak"
|
| 639 |
+
checked
|
| 640 |
+
/>
|
| 641 |
+
Tidak</label
|
| 642 |
+
>
|
| 643 |
+
</div>
|
| 644 |
+
</div>
|
| 645 |
+
</div>
|
| 646 |
|
| 647 |
+
<p class="section-header">Perilaku dan Kebiasaan</p>
|
| 648 |
+
<div class="questions-container">
|
| 649 |
+
<div class="question">
|
| 650 |
+
<label>Apakah Anda mudah bereaksi berlebihan?</label>
|
| 651 |
+
<div class="radio-group">
|
| 652 |
+
<label class="radio-option"
|
| 653 |
+
><input type="radio" name="over_react" value="Ya" />
|
| 654 |
+
Ya</label
|
| 655 |
+
>
|
| 656 |
+
<label class="radio-option"
|
| 657 |
+
><input
|
| 658 |
+
type="radio"
|
| 659 |
+
name="over_react"
|
| 660 |
+
value="Tidak"
|
| 661 |
+
checked
|
| 662 |
+
/>
|
| 663 |
+
Tidak</label
|
| 664 |
+
>
|
| 665 |
+
</div>
|
| 666 |
+
</div>
|
| 667 |
|
| 668 |
+
<div class="question">
|
| 669 |
+
<label>Apakah ada perubahan pola makan?</label>
|
| 670 |
+
<div class="radio-group">
|
| 671 |
+
<label class="radio-option"
|
| 672 |
+
><input type="radio" name="change_in_eating" value="Ya" />
|
| 673 |
+
Ya</label
|
| 674 |
+
>
|
| 675 |
+
<label class="radio-option"
|
| 676 |
+
><input
|
| 677 |
+
type="radio"
|
| 678 |
+
name="change_in_eating"
|
| 679 |
+
value="Tidak"
|
| 680 |
+
checked
|
| 681 |
+
/>
|
| 682 |
+
Tidak</label
|
| 683 |
+
>
|
| 684 |
+
</div>
|
| 685 |
+
</div>
|
| 686 |
|
| 687 |
+
<div class="question">
|
| 688 |
+
<label
|
| 689 |
+
>Apakah Anda pernah memiliki pikiran untuk bunuh diri?</label
|
| 690 |
+
>
|
| 691 |
+
<div class="radio-group">
|
| 692 |
+
<label class="radio-option"
|
| 693 |
+
><input type="radio" name="suicidal_thought" value="Ya" />
|
| 694 |
+
Ya</label
|
| 695 |
+
>
|
| 696 |
+
<label class="radio-option"
|
| 697 |
+
><input
|
| 698 |
+
type="radio"
|
| 699 |
+
name="suicidal_thought"
|
| 700 |
+
value="Tidak"
|
| 701 |
+
checked
|
| 702 |
+
/>
|
| 703 |
+
Tidak</label
|
| 704 |
+
>
|
| 705 |
+
</div>
|
| 706 |
+
</div>
|
| 707 |
|
| 708 |
+
<div class="question">
|
| 709 |
+
<label>Apakah Anda kecanduan media sosial?</label>
|
| 710 |
+
<div class="radio-group">
|
| 711 |
+
<label class="radio-option"
|
| 712 |
+
><input
|
| 713 |
+
type="radio"
|
| 714 |
+
name="social_media_addiction"
|
| 715 |
+
value="Ya"
|
| 716 |
+
/>
|
| 717 |
+
Ya</label
|
| 718 |
+
>
|
| 719 |
+
<label class="radio-option"
|
| 720 |
+
><input
|
| 721 |
+
type="radio"
|
| 722 |
+
name="social_media_addiction"
|
| 723 |
+
value="Tidak"
|
| 724 |
+
checked
|
| 725 |
+
/>
|
| 726 |
+
Tidak</label
|
| 727 |
+
>
|
| 728 |
+
</div>
|
| 729 |
+
</div>
|
| 730 |
|
| 731 |
+
<div class="question">
|
| 732 |
+
<label>Apakah Anda memiliki perilaku yang repetitif?</label>
|
| 733 |
+
<div class="radio-group">
|
| 734 |
+
<label class="radio-option"
|
| 735 |
+
><input
|
| 736 |
+
type="radio"
|
| 737 |
+
name="repetitive_behaviour"
|
| 738 |
+
value="Ya"
|
| 739 |
+
/>
|
| 740 |
+
Ya</label
|
| 741 |
+
>
|
| 742 |
+
<label class="radio-option"
|
| 743 |
+
><input
|
| 744 |
+
type="radio"
|
| 745 |
+
name="repetitive_behaviour"
|
| 746 |
+
value="Tidak"
|
| 747 |
+
checked
|
| 748 |
+
/>
|
| 749 |
+
Tidak</label
|
| 750 |
+
>
|
| 751 |
+
</div>
|
| 752 |
+
</div>
|
| 753 |
+
</div>
|
| 754 |
|
| 755 |
+
<p class="section-header">Sosial dan Pengalaman</p>
|
| 756 |
+
<div class="questions-container">
|
| 757 |
+
<div class="question">
|
| 758 |
+
<label>Apakah Anda memiliki teman dekat?</label>
|
| 759 |
+
<div class="radio-group">
|
| 760 |
+
<label class="radio-option"
|
| 761 |
+
><input type="radio" name="close_friend" value="Ya" />
|
| 762 |
+
Ya</label
|
| 763 |
+
>
|
| 764 |
+
<label class="radio-option"
|
| 765 |
+
><input
|
| 766 |
+
type="radio"
|
| 767 |
+
name="close_friend"
|
| 768 |
+
value="Tidak"
|
| 769 |
+
checked
|
| 770 |
+
/>
|
| 771 |
+
Tidak</label
|
| 772 |
+
>
|
| 773 |
+
</div>
|
| 774 |
+
</div>
|
| 775 |
|
| 776 |
+
<div class="question">
|
| 777 |
+
<label>Apakah Anda seorang introvert?</label>
|
| 778 |
+
<div class="radio-group">
|
| 779 |
+
<label class="radio-option"
|
| 780 |
+
><input type="radio" name="introvert" value="Ya" />
|
| 781 |
+
Ya</label
|
| 782 |
+
>
|
| 783 |
+
<label class="radio-option"
|
| 784 |
+
><input
|
| 785 |
+
type="radio"
|
| 786 |
+
name="introvert"
|
| 787 |
+
value="Tidak"
|
| 788 |
+
checked
|
| 789 |
+
/>
|
| 790 |
+
Tidak</label
|
| 791 |
+
>
|
| 792 |
+
</div>
|
| 793 |
+
</div>
|
| 794 |
|
| 795 |
+
<div class="question">
|
| 796 |
+
<label>Apakah sering muncul ingatan yang membuat stres?</label>
|
| 797 |
+
<div class="radio-group">
|
| 798 |
+
<label class="radio-option"
|
| 799 |
+
><input
|
| 800 |
+
type="radio"
|
| 801 |
+
name="popping_up_stressful_memory"
|
| 802 |
+
value="Ya"
|
| 803 |
+
/>
|
| 804 |
+
Ya</label
|
| 805 |
+
>
|
| 806 |
+
<label class="radio-option"
|
| 807 |
+
><input
|
| 808 |
+
type="radio"
|
| 809 |
+
name="popping_up_stressful_memory"
|
| 810 |
+
value="Tidak"
|
| 811 |
+
checked
|
| 812 |
+
/>
|
| 813 |
+
Tidak</label
|
| 814 |
+
>
|
| 815 |
+
</div>
|
| 816 |
+
</div>
|
| 817 |
|
| 818 |
+
<div class="question">
|
| 819 |
+
<label
|
| 820 |
+
>Apakah Anda menghindari orang atau aktivitas tertentu?</label
|
| 821 |
+
>
|
| 822 |
+
<div class="radio-group">
|
| 823 |
+
<label class="radio-option"
|
| 824 |
+
><input
|
| 825 |
+
type="radio"
|
| 826 |
+
name="avoids_people_or_activities"
|
| 827 |
+
value="Ya"
|
| 828 |
+
/>
|
| 829 |
+
Ya</label
|
| 830 |
+
>
|
| 831 |
+
<label class="radio-option"
|
| 832 |
+
><input
|
| 833 |
+
type="radio"
|
| 834 |
+
name="avoids_people_or_activities"
|
| 835 |
+
value="Tidak"
|
| 836 |
+
checked
|
| 837 |
+
/>
|
| 838 |
+
Tidak</label
|
| 839 |
+
>
|
| 840 |
+
</div>
|
| 841 |
+
</div>
|
| 842 |
+
</div>
|
| 843 |
|
| 844 |
+
<p class="section-header">Lainnya</p>
|
| 845 |
+
<div class="questions-container">
|
| 846 |
+
<div class="question">
|
| 847 |
+
<label>Apakah Anda mengalami halusinasi?</label>
|
| 848 |
+
<div class="radio-group">
|
| 849 |
+
<label class="radio-option"
|
| 850 |
+
><input type="radio" name="hallucinations" value="Ya" />
|
| 851 |
+
Ya</label
|
| 852 |
+
>
|
| 853 |
+
<label class="radio-option"
|
| 854 |
+
><input
|
| 855 |
+
type="radio"
|
| 856 |
+
name="hallucinations"
|
| 857 |
+
value="Tidak"
|
| 858 |
+
checked
|
| 859 |
+
/>
|
| 860 |
+
Tidak</label
|
| 861 |
+
>
|
| 862 |
+
</div>
|
| 863 |
+
</div>
|
| 864 |
+
|
| 865 |
+
<div class="question">
|
| 866 |
+
<label>Apakah gejala Anda muncul secara musiman?</label>
|
| 867 |
+
<div class="radio-group">
|
| 868 |
+
<label class="radio-option"
|
| 869 |
+
><input type="radio" name="seasonally" value="Ya" />
|
| 870 |
+
Ya</label
|
| 871 |
+
>
|
| 872 |
+
<label class="radio-option"
|
| 873 |
+
><input
|
| 874 |
+
type="radio"
|
| 875 |
+
name="seasonally"
|
| 876 |
+
value="Tidak"
|
| 877 |
+
checked
|
| 878 |
+
/>
|
| 879 |
+
Tidak</label
|
| 880 |
+
>
|
| 881 |
+
</div>
|
| 882 |
+
</div>
|
| 883 |
+
</div>
|
| 884 |
+
</div>
|
| 885 |
</div>
|
| 886 |
|
| 887 |
<!-- Submit Button -->
|
| 888 |
+
<button type="submit">Submit Kuesioner</button>
|
| 889 |
+
</form>
|
| 890 |
+
|
| 891 |
+
<!-- Loading spinner -->
|
| 892 |
+
<div class="spinner" id="loading-spinner"></div>
|
| 893 |
|
| 894 |
+
<!-- Display Result -->
|
| 895 |
+
<div class="result" id="result">
|
| 896 |
<h2>{{ result }}</h2>
|
| 897 |
+
</div>
|
| 898 |
+
|
| 899 |
+
<!-- Attribution Section -->
|
| 900 |
+
<div class="attribution">
|
| 901 |
+
<h3>Tentang Aplikasi</h3>
|
| 902 |
+
<p>
|
| 903 |
+
Aplikasi ini adalah fork dari
|
| 904 |
+
<a href="{{ app_info.original_repo }}" target="_blank"
|
| 905 |
+
>Mentalys-App/tabular_ml</a
|
| 906 |
+
>
|
| 907 |
+
dan dibuat oleh
|
| 908 |
+
<a href="{{ app_info.author_url }}" target="_blank"
|
| 909 |
+
>{{ app_info.author }}</a
|
| 910 |
+
>.
|
| 911 |
+
</p>
|
| 912 |
+
<p>
|
| 913 |
+
Dikembangkan oleh
|
| 914 |
+
<a href="{{ app_info.organization_url }}" target="_blank"
|
| 915 |
+
>{{ app_info.organization }}</a
|
| 916 |
+
>.
|
| 917 |
+
</p>
|
| 918 |
+
</div>
|
| 919 |
+
|
| 920 |
+
<footer>
|
| 921 |
+
© 2023 {{ app_info.organization }} - Aplikasi Prediksi Gangguan
|
| 922 |
+
Mental
|
| 923 |
+
</footer>
|
| 924 |
</div>
|
| 925 |
|
| 926 |
<script>
|
| 927 |
+
document.addEventListener("DOMContentLoaded", function () {
|
| 928 |
+
const form = document.getElementById("prediction-form");
|
| 929 |
+
const resultDiv = document.getElementById("result");
|
| 930 |
+
const spinner = document.getElementById("loading-spinner");
|
| 931 |
+
|
| 932 |
+
// Hide result initially if no result
|
| 933 |
+
if (!resultDiv.textContent.trim()) {
|
| 934 |
+
resultDiv.style.display = "none";
|
| 935 |
+
}
|
| 936 |
+
|
| 937 |
+
form.addEventListener("submit", function (e) {
|
| 938 |
+
e.preventDefault();
|
| 939 |
+
|
| 940 |
+
// Show loading spinner
|
| 941 |
+
spinner.style.display = "block";
|
| 942 |
+
resultDiv.style.display = "none";
|
| 943 |
+
|
| 944 |
+
const formData = new FormData(form);
|
| 945 |
+
|
| 946 |
+
fetch("/", {
|
| 947 |
+
method: "POST",
|
| 948 |
+
body: formData,
|
| 949 |
+
})
|
| 950 |
+
.then((response) => response.json())
|
| 951 |
+
.then((data) => {
|
| 952 |
+
// Hide spinner
|
| 953 |
+
spinner.style.display = "none";
|
| 954 |
+
|
| 955 |
+
// Show result
|
| 956 |
+
resultDiv.innerHTML = `<h2>${data.result}</h2>`;
|
| 957 |
+
resultDiv.style.display = "block";
|
| 958 |
+
resultDiv.classList.add("active", "fade-in");
|
| 959 |
+
|
| 960 |
+
// Scroll to result
|
| 961 |
+
resultDiv.scrollIntoView({ behavior: "smooth", block: "center" });
|
| 962 |
+
})
|
| 963 |
+
.catch((error) => {
|
| 964 |
+
console.error("Error:", error);
|
| 965 |
+
spinner.style.display = "none";
|
| 966 |
+
resultDiv.innerHTML =
|
| 967 |
+
"<h2>Terjadi kesalahan saat memproses permintaan.</h2>";
|
| 968 |
+
resultDiv.style.display = "block";
|
| 969 |
});
|
| 970 |
});
|
| 971 |
+
});
|
| 972 |
</script>
|
| 973 |
+
</body>
|
| 974 |
</html>
|