-
Notifications
You must be signed in to change notification settings - Fork 1.6k
( NEW ) Menambahkan diagram UML dan update README #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Ghuulaam
wants to merge
3
commits into
mmumshad:master
Choose a base branch
from
Ghuulaam:GhulamRPLUAS
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,80 @@ | ||
import os | ||
from flask import Flask | ||
from flask import Flask, render_template, request, redirect, url_for, session | ||
|
||
app = Flask(__name__) | ||
app.secret_key = 'rahasia' # Digunakan untuk menyimpan session login | ||
|
||
# Akun pengguna (dummy) | ||
USER_CREDENTIALS = { | ||
'admin': 'admin' | ||
} | ||
|
||
# ======================== | ||
# ROUTE: Halaman Login | ||
# ======================== | ||
@app.route("/") | ||
def main(): | ||
return "Welcome!" | ||
def index(): | ||
return render_template("login.html") | ||
|
||
# ======================== | ||
# ROUTE: Proses Login | ||
# ======================== | ||
@app.route("/login", methods=["POST"]) | ||
def login(): | ||
username = request.form.get("username") | ||
password = request.form.get("password") | ||
|
||
if username in USER_CREDENTIALS and USER_CREDENTIALS[username] == password: | ||
session['user'] = username | ||
return redirect(url_for('dashboard')) | ||
else: | ||
return """ | ||
<h3>Login gagal!</h3> | ||
<p>Username atau password salah.</p> | ||
<a href='/'>Kembali ke login</a> | ||
""" | ||
|
||
# ======================== | ||
# ROUTE: Dashboard | ||
# ======================== | ||
@app.route("/dashboard") | ||
def dashboard(): | ||
if 'user' not in session: | ||
return redirect(url_for('index')) | ||
return render_template("dashboard.html") | ||
|
||
# ======================== | ||
# ROUTE: Tambah Data | ||
# ======================== | ||
@app.route("/create", methods=["GET", "POST"]) | ||
def create(): | ||
if 'user' not in session: | ||
return redirect(url_for('index')) | ||
|
||
if request.method == "POST": | ||
nama = request.form.get("nama") | ||
jumlah = request.form.get("jumlah") | ||
|
||
if nama and jumlah: | ||
print(f"Data disimpan: {nama}, jumlah: {jumlah}") # Log ke terminal | ||
return render_template("success.html") | ||
else: | ||
return """ | ||
<h3>Data tidak lengkap!</h3> | ||
<a href='/create'>Coba lagi</a> | ||
""" | ||
|
||
return render_template("create.html") | ||
|
||
@app.route('/how are you') | ||
def hello(): | ||
return 'I am good, how about you?' | ||
# ======================== | ||
# ROUTE: Logout | ||
# ======================== | ||
@app.route("/logout") | ||
def logout(): | ||
session.pop('user', None) | ||
return render_template("logout.html") | ||
|
||
# ======================== | ||
# RUN APP | ||
# ======================== | ||
if __name__ == "__main__": | ||
app.run(host="0.0.0.0", port=8080) |
Ghuulaam marked this conversation as resolved.
Show resolved
Hide resolved
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Ghuulaam marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@startuml | ||
class User { | ||
-username: str | ||
-password: str | ||
+login(): bool | ||
} | ||
|
||
class Item { | ||
-name: str | ||
-description: str | ||
+create(): void | ||
} | ||
|
||
User "1" --> "*" Item : creates | ||
@enduml |
Ghuulaam marked this conversation as resolved.
Show resolved
Hide resolved
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Ghuulaam marked this conversation as resolved.
Show resolved
Hide resolved
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Ghuulaam marked this conversation as resolved.
Show resolved
Hide resolved
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Ghuulaam marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@startuml | ||
actor Admin | ||
participant WebBrowser | ||
participant FlaskApp | ||
participant ItemService | ||
participant Database | ||
|
||
Admin -> WebBrowser : buka halaman create item | ||
WebBrowser -> FlaskApp : GET /item/create | ||
FlaskApp -> WebBrowser : tampilkan form | ||
|
||
Admin -> WebBrowser : submit data item | ||
WebBrowser -> FlaskApp : POST /item/create | ||
FlaskApp -> ItemService : validasi data | ||
ItemService -> Database : simpan item | ||
Database --> ItemService : sukses | ||
ItemService --> FlaskApp : status OK | ||
FlaskApp -> WebBrowser : tampilkan pesan sukses | ||
@enduml |
Ghuulaam marked this conversation as resolved.
Show resolved
Hide resolved
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Ghuulaam marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@startuml | ||
actor User | ||
participant WebBrowser | ||
participant FlaskApp | ||
participant AuthService | ||
participant Database | ||
|
||
User -> WebBrowser : buka halaman login | ||
WebBrowser -> FlaskApp : GET /login | ||
FlaskApp -> WebBrowser : tampilkan form | ||
|
||
User -> WebBrowser : isi username dan password | ||
WebBrowser -> FlaskApp : POST /validateLogin | ||
FlaskApp -> AuthService : validasi login | ||
AuthService -> Database : ambil data user | ||
Database --> AuthService : data user | ||
AuthService --> FlaskApp : hasil validasi | ||
FlaskApp -> WebBrowser : redirect ke dashboard / error | ||
@enduml |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.