Spaces:
Running
Running
Bintang Fajar Julio
commited on
Commit
•
6954bf4
1
Parent(s):
a1b428e
update
Browse files- .gitignore +1 -0
- Dockerfile +0 -9
- app.py +0 -2
- models/history.py +3 -1
- models/user.py +3 -1
- requirements.txt +2 -1
- templates/dashboard/classifier.html +7 -1
- templates/dashboard/file.html +1 -1
- templates/dashboard/lecturer.html +1 -1
- templates/dashboard/user.html +1 -1
- views/auth.py +3 -1
- views/classifier.py +3 -1
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
**/__pycache__/
|
Dockerfile
CHANGED
@@ -1,15 +1,6 @@
|
|
1 |
# Use Python 3.12.3 base image
|
2 |
FROM python:3.12.3
|
3 |
|
4 |
-
RUN apt-get update && apt-get install -y locales && \
|
5 |
-
locale-gen id_ID.UTF-8 && \
|
6 |
-
dpkg-reconfigure locales && \
|
7 |
-
locale -a
|
8 |
-
|
9 |
-
ENV LANG=id_ID.UTF-8
|
10 |
-
ENV LC_ALL=id_ID.UTF-8
|
11 |
-
|
12 |
-
|
13 |
# Create a non-root user
|
14 |
RUN useradd -m -u 1000 user
|
15 |
|
|
|
1 |
# Use Python 3.12.3 base image
|
2 |
FROM python:3.12.3
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
# Create a non-root user
|
5 |
RUN useradd -m -u 1000 user
|
6 |
|
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import os
|
2 |
import middleware
|
3 |
-
import locale
|
4 |
|
5 |
from dotenv import load_dotenv
|
6 |
from flask import Flask, redirect, render_template, url_for
|
@@ -9,7 +8,6 @@ from flask_login import current_user
|
|
9 |
from inference_config import Inference
|
10 |
|
11 |
|
12 |
-
# locale.setlocale(locale.LC_TIME, 'id_ID')
|
13 |
load_dotenv(override=True)
|
14 |
|
15 |
app = Flask(__name__, static_folder='static', template_folder='templates')
|
|
|
1 |
import os
|
2 |
import middleware
|
|
|
3 |
|
4 |
from dotenv import load_dotenv
|
5 |
from flask import Flask, redirect, render_template, url_for
|
|
|
8 |
from inference_config import Inference
|
9 |
|
10 |
|
|
|
11 |
load_dotenv(override=True)
|
12 |
|
13 |
app = Flask(__name__, static_folder='static', template_folder='templates')
|
models/history.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
from firebase_config import firebase_db
|
2 |
from firebase_admin import firestore
|
3 |
|
@@ -47,7 +49,7 @@ class History:
|
|
47 |
'kata_kunci': data['kata_kunci'],
|
48 |
'probabilitas': dict(sorted(data['probabilitas'].items(), key=lambda item: item[1], reverse=True)),
|
49 |
'kelompok_bidang_keahlian': data['kelompok_bidang_keahlian'],
|
50 |
-
'tanggal_inferensi': data['tanggal_inferensi'].
|
51 |
'top_similarity': data['top_similarity']
|
52 |
})
|
53 |
|
|
|
1 |
+
import arrow
|
2 |
+
|
3 |
from firebase_config import firebase_db
|
4 |
from firebase_admin import firestore
|
5 |
|
|
|
49 |
'kata_kunci': data['kata_kunci'],
|
50 |
'probabilitas': dict(sorted(data['probabilitas'].items(), key=lambda item: item[1], reverse=True)),
|
51 |
'kelompok_bidang_keahlian': data['kelompok_bidang_keahlian'],
|
52 |
+
'tanggal_inferensi': arrow.get(data['tanggal_inferensi']).to('Asia/Jakarta').format('dddd, DD-MM-YYYY HH:mm:ss', locale='id_ID'),
|
53 |
'top_similarity': data['top_similarity']
|
54 |
})
|
55 |
|
models/user.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
from flask_login import UserMixin
|
2 |
from firebase_config import firebase_db
|
3 |
from firebase_admin import firestore
|
@@ -34,7 +36,7 @@ class User(UserMixin):
|
|
34 |
'email': data['email'],
|
35 |
'role': data['role'],
|
36 |
'inactive': data['inactive'],
|
37 |
-
'registered_at': data['registered_at'].
|
38 |
'status_badge': 'danger' if data['inactive'] == "1" else 'success'
|
39 |
})
|
40 |
|
|
|
1 |
+
import arrow
|
2 |
+
|
3 |
from flask_login import UserMixin
|
4 |
from firebase_config import firebase_db
|
5 |
from firebase_admin import firestore
|
|
|
36 |
'email': data['email'],
|
37 |
'role': data['role'],
|
38 |
'inactive': data['inactive'],
|
39 |
+
'registered_at': arrow.get(data['registered_at']).to('Asia/Jakarta').format('dddd, DD-MM-YYYY HH:mm:ss', locale='id_ID'),
|
40 |
'status_badge': 'danger' if data['inactive'] == "1" else 'success'
|
41 |
})
|
42 |
|
requirements.txt
CHANGED
@@ -10,4 +10,5 @@ torch
|
|
10 |
scikit-learn
|
11 |
transformers
|
12 |
Sastrawi
|
13 |
-
emoji
|
|
|
|
10 |
scikit-learn
|
11 |
transformers
|
12 |
Sastrawi
|
13 |
+
emoji
|
14 |
+
arrow
|
templates/dashboard/classifier.html
CHANGED
@@ -540,9 +540,15 @@ title %} {% block content %}
|
|
540 |
}
|
541 |
|
542 |
$("#hasil").removeClass("d-none");
|
543 |
-
window.location.hash = "hasil";
|
544 |
$(".spinner").addClass("d-none");
|
545 |
$(".overlay").addClass("d-none");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
546 |
},
|
547 |
error: function (response) {
|
548 |
$(".spinner").addClass("d-none");
|
|
|
540 |
}
|
541 |
|
542 |
$("#hasil").removeClass("d-none");
|
|
|
543 |
$(".spinner").addClass("d-none");
|
544 |
$(".overlay").addClass("d-none");
|
545 |
+
|
546 |
+
$("html, body").animate(
|
547 |
+
{
|
548 |
+
scrollTop: $("#hasil").offset().top - 50,
|
549 |
+
},
|
550 |
+
1000
|
551 |
+
);
|
552 |
},
|
553 |
error: function (response) {
|
554 |
$(".spinner").addClass("d-none");
|
templates/dashboard/file.html
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
{% extends 'dashboard/base.html' %} {% block title %}Berkas{% endblock title %}
|
2 |
{% block content %}
|
3 |
-
<div class="row g-3 mb-
|
4 |
<div class="col-auto">
|
5 |
<h1 class="app-page-title mb-0">Berkas</h1>
|
6 |
</div>
|
|
|
1 |
{% extends 'dashboard/base.html' %} {% block title %}Berkas{% endblock title %}
|
2 |
{% block content %}
|
3 |
+
<div class="row g-3 mb-4 align-items-center justify-content-between">
|
4 |
<div class="col-auto">
|
5 |
<h1 class="app-page-title mb-0">Berkas</h1>
|
6 |
</div>
|
templates/dashboard/lecturer.html
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
{% extends 'dashboard/base.html' %} {% block title %}Dosen{% endblock title %}
|
2 |
{% block content %}
|
3 |
-
<div class="row g-3 mb-
|
4 |
<div class="col-auto">
|
5 |
<h1 class="app-page-title mb-0">Dosen</h1>
|
6 |
</div>
|
|
|
1 |
{% extends 'dashboard/base.html' %} {% block title %}Dosen{% endblock title %}
|
2 |
{% block content %}
|
3 |
+
<div class="row g-3 mb-4 align-items-center justify-content-between">
|
4 |
<div class="col-auto">
|
5 |
<h1 class="app-page-title mb-0">Dosen</h1>
|
6 |
</div>
|
templates/dashboard/user.html
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
{% extends 'dashboard/base.html' %} {% block title %}Pengguna{% endblock title
|
2 |
%} {% block content %}
|
3 |
-
<div class="row g-3 mb-
|
4 |
<div class="col-auto">
|
5 |
<h1 class="app-page-title mb-0">Pengguna</h1>
|
6 |
</div>
|
|
|
1 |
{% extends 'dashboard/base.html' %} {% block title %}Pengguna{% endblock title
|
2 |
%} {% block content %}
|
3 |
+
<div class="row g-3 mb-4 align-items-center justify-content-between">
|
4 |
<div class="col-auto">
|
5 |
<h1 class="app-page-title mb-0">Pengguna</h1>
|
6 |
</div>
|
views/auth.py
CHANGED
@@ -6,9 +6,11 @@ from requests.exceptions import HTTPError
|
|
6 |
from firebase_config import firebase_auth, firebase_db
|
7 |
from flask_login import logout_user, login_user
|
8 |
from middleware import load_user
|
|
|
9 |
|
10 |
|
11 |
auth = Blueprint('auth', __name__, template_folder='templates')
|
|
|
12 |
|
13 |
@auth.route('/sign-up', methods=['GET', 'POST'])
|
14 |
def sign_up():
|
@@ -33,7 +35,7 @@ def sign_up():
|
|
33 |
'nama': nama,
|
34 |
'email': email,
|
35 |
'role': 'pengguna',
|
36 |
-
'registered_at': datetime.now(),
|
37 |
'inactive': '0'
|
38 |
}
|
39 |
|
|
|
6 |
from firebase_config import firebase_auth, firebase_db
|
7 |
from flask_login import logout_user, login_user
|
8 |
from middleware import load_user
|
9 |
+
from pytz import timezone
|
10 |
|
11 |
|
12 |
auth = Blueprint('auth', __name__, template_folder='templates')
|
13 |
+
tz = timezone('Asia/Jakarta')
|
14 |
|
15 |
@auth.route('/sign-up', methods=['GET', 'POST'])
|
16 |
def sign_up():
|
|
|
35 |
'nama': nama,
|
36 |
'email': email,
|
37 |
'role': 'pengguna',
|
38 |
+
'registered_at': datetime.now(tz),
|
39 |
'inactive': '0'
|
40 |
}
|
41 |
|
views/classifier.py
CHANGED
@@ -4,9 +4,11 @@ from models.lecturer import Lecturer
|
|
4 |
from models.history import History
|
5 |
from datetime import datetime
|
6 |
from flask_login import current_user
|
|
|
7 |
|
8 |
|
9 |
classifier = Blueprint('classifier', __name__, template_folder='templates', url_prefix='/dashboard/classifier')
|
|
|
10 |
|
11 |
@classifier.route('/inference', methods=['POST'])
|
12 |
@role_required('pengguna')
|
@@ -22,7 +24,7 @@ def inference():
|
|
22 |
|
23 |
recommended = current_app.inference.content_based_filtering(text)
|
24 |
|
25 |
-
history = History(abstrak=abstrak, kata_kunci=kata_kunci, probabilitas=probs, kelompok_bidang_keahlian=kbk, tanggal_inferensi=datetime.now(), top_similarity=recommended)
|
26 |
history.save(current_user.id)
|
27 |
|
28 |
return jsonify(message={'probs': probs, 'lecturers': lecturers, 'kbk': kbk, 'top_similarity': recommended}, status="success"), 200
|
|
|
4 |
from models.history import History
|
5 |
from datetime import datetime
|
6 |
from flask_login import current_user
|
7 |
+
from pytz import timezone
|
8 |
|
9 |
|
10 |
classifier = Blueprint('classifier', __name__, template_folder='templates', url_prefix='/dashboard/classifier')
|
11 |
+
tz = timezone('Asia/Jakarta')
|
12 |
|
13 |
@classifier.route('/inference', methods=['POST'])
|
14 |
@role_required('pengguna')
|
|
|
24 |
|
25 |
recommended = current_app.inference.content_based_filtering(text)
|
26 |
|
27 |
+
history = History(abstrak=abstrak, kata_kunci=kata_kunci, probabilitas=probs, kelompok_bidang_keahlian=kbk, tanggal_inferensi=datetime.now(tz), top_similarity=recommended)
|
28 |
history.save(current_user.id)
|
29 |
|
30 |
return jsonify(message={'probs': probs, 'lecturers': lecturers, 'kbk': kbk, 'top_similarity': recommended}, status="success"), 200
|