varunkuntal commited on
Commit
06f4ba9
1 Parent(s): 09e6f1b
Dockerfile ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use a official Python runtime as a parent image
2
+ FROM python:3.8-slim-buster
3
+
4
+ # Set the working directory in the container
5
+ WORKDIR /app
6
+
7
+ # Copy the current directory contents into the container
8
+ ADD . /app
9
+
10
+ # Install any needed packages specified in requirements.txt
11
+ RUN pip install --no-cache-dir -r requirements.txt
12
+
13
+ # Make port 80 available to the world outside this container
14
+ EXPOSE 80
15
+
16
+ # Run app.py when the container launches
17
+ CMD ["gunicorn", "-b", ":80", "app:app"]
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, render_template
2
+ import pickle
3
+
4
+ # Load the model from the pickle file
5
+ with open('gs_clf.pickle', 'rb') as f:
6
+ spam_classifier = pickle.load(f)
7
+
8
+
9
+ # Load the spam classifier
10
+ app = Flask(__name__)
11
+
12
+ @app.route('/', methods=['GET', 'POST'])
13
+ def classify_message():
14
+ if request.method == 'POST':
15
+ message = request.form['message']
16
+ print(message)
17
+ prediction = spam_classifier.predict([message])
18
+ print(prediction)
19
+ return render_template('index.html', prediction=prediction[0])
20
+
21
+ return render_template('index.html', prediction=None)
22
+
23
+
24
+ if __name__ == '__main__':
25
+ app.run(host='0.0.0.0', port=5000)
gs_clf.pickle ADDED
Binary file (942 kB). View file
 
gs_clf.pickle:Zone.Identifier ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [ZoneTransfer]
2
+ ZoneId=3
3
+ HostUrl=about:internet
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ Flask
2
+ gunicorn
3
+ scikit-learn
static/style.css ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body {
2
+ font-family: Arial, sans-serif;
3
+ color: #333;
4
+ background-color: #f9f9f9;
5
+ padding: 30px;
6
+ }
7
+
8
+ .container {
9
+ display: flex;
10
+ flex-direction: column;
11
+ align-items: center;
12
+ justify-content: center;
13
+ height: 100vh;
14
+ text-align: center;
15
+ }
16
+
17
+ textarea, button {
18
+ width: 300px;
19
+ margin-bottom: 20px;
20
+ padding: 10px;
21
+ font-size: 1em;
22
+ border: none;
23
+ border-radius: 5px;
24
+ }
25
+
26
+ textarea {
27
+ height: 100px;
28
+ resize: none;
29
+ }
30
+
31
+ button {
32
+ color: #fff;
33
+ background-color: #007BFF;
34
+ cursor: pointer;
35
+ transition: background-color 0.3s ease;
36
+ }
37
+
38
+ button:hover {
39
+ background-color: #0056b3;
40
+ }
41
+
42
+ .result {
43
+ font-size: 1.5em;
44
+ }
templates/index.html ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Spam Classifier App</title>
6
+ <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
7
+ </head>
8
+ <body>
9
+ <div class="container">
10
+ <h1>Spam Classifier</h1>
11
+ <form method="POST">
12
+ <textarea name="message" required></textarea>
13
+ <button type="submit">Classify</button>
14
+ </form>
15
+ {% if prediction %}
16
+ <div class="result">Classification Result: {{ prediction }}</div>
17
+ {% endif %}
18
+ </div>
19
+ </body>
20
+ </html>