File size: 3,464 Bytes
9f41fd4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Product Health Check</title>
    <style>
      body {
        font-family: Arial, sans-serif;
        max-width: 1200px;
        margin: 0 auto;
        padding: 20px;
      }
      h1 {
        text-align: center;
        margin-bottom: 30px;
      }
      .form-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-bottom: 30px;
      }
      .input-row {
        display: flex;
        width: 100%;
        max-width: 600px;
        margin-top: 10px;
      }
      .input-label {
        display: block;
        margin-bottom: 5px;
        font-weight: bold;
      }
      input[type="text"] {
        flex-grow: 1;
        padding: 8px;
        font-size: 16px;
        border: 1px solid #ccc;
        border-radius: 4px;
      }
      button {
        margin-left: 10px;
        padding: 8px 16px;
        font-size: 16px;
        background-color: #4caf50;
        color: white;
        border: none;
        border-radius: 4px;
        cursor: pointer;
      }
      button[name="refresh"] {
        background-color: #f44336;
      }
      .error {
        color: red;
        margin: 15px 0;
        text-align: center;
      }
      .results {
        margin-top: 20px;
      }
      .results-header {
        margin-bottom: 20px;
      }
      .results-columns {
        display: flex;
        gap: 20px;
      }
      .column {
        flex: 1;
        border: 1px solid #ddd;
        border-radius: 4px;
        padding: 15px;
      }
      .column h3 {
        margin-top: 0;
      }
      img {
        max-width: 100%;
        height: auto;
      }
    </style>
  </head>
  <body>
    <h1>Check Your Products Health</h1>

    <div class="form-container">
      <div class="input-label">
        Enter Product Code (ASIN): ASIN is a 10 digit number
      </div>
      <form method="POST" class="input-row">
        <input
          type="text"
          name="product_code"
          value="{{ request.form.get('product_code', '') }}"
        />
        <button type="submit" name="generate" value="true">Generate</button>
        <button type="submit" name="refresh" value="true">Refresh</button>
      </form>
    </div>

    {% if error %}
    <div class="error">{{ error }}</div>
    {% endif %} {% if result %}
    <div class="results">
      <div class="results-header">
        <h2>Product ID: {{ result.product_code }}</h2>
        <p>Total Reviews: {{ result.total_reviews }}</p>
      </div>

      <div class="results-columns">
        <div class="column">
          <h3>
            Positive Reviews: {{ "%.2f"|format(result.positive_percentage) }}%
          </h3>
          {% if result.positive_wordcloud %}
          <img
            src="data:image/png;base64,{{ result.positive_wordcloud }}"
            alt="Positive Reviews Word Cloud"
          />
          {% endif %}
        </div>

        <div class="column">
          <h3>
            Negative Reviews: {{ "%.2f"|format(result.negative_percentage) }}%
          </h3>
          {% if result.negative_wordcloud %}
          <img
            src="data:image/png;base64,{{ result.negative_wordcloud }}"
            alt="Negative Reviews Word Cloud"
          />
          {% endif %}
        </div>
      </div>
    </div>
    {% endif %}
  </body>
</html>