Spaces:
Sleeping
Sleeping
Upload 9 files
Browse files- Dockerfile +10 -0
- app.py +105 -0
- requirements.txt +5 -0
- static/style.css +80 -0
- templates/base.html +21 -0
- templates/dashboard.html +70 -0
- templates/login.html +15 -0
- templates/portfolio.html +11 -0
- templates/signup.html +16 -0
Dockerfile
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.10
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
COPY requirements.txt .
|
| 6 |
+
RUN pip install -r requirements.txt
|
| 7 |
+
|
| 8 |
+
COPY . .
|
| 9 |
+
|
| 10 |
+
CMD ["python", "app.py"]
|
app.py
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, render_template, request, redirect, url_for, session, flash
|
| 2 |
+
from werkzeug.security import generate_password_hash, check_password_hash
|
| 3 |
+
|
| 4 |
+
# ML imports
|
| 5 |
+
import seaborn as sns
|
| 6 |
+
from sklearn.linear_model import LogisticRegression
|
| 7 |
+
import numpy as np
|
| 8 |
+
|
| 9 |
+
app = Flask(__name__)
|
| 10 |
+
app.secret_key = "supersecretkey" # ⚠️ change this in production!
|
| 11 |
+
|
| 12 |
+
# ----------------------------
|
| 13 |
+
# Train Iris Model (once only)
|
| 14 |
+
# ----------------------------
|
| 15 |
+
iris = sns.load_dataset("iris")
|
| 16 |
+
X = iris.iloc[:, 0:4].values
|
| 17 |
+
y = iris.iloc[:, 4].values
|
| 18 |
+
|
| 19 |
+
iris_model = LogisticRegression(max_iter=300)
|
| 20 |
+
iris_model.fit(X, y)
|
| 21 |
+
|
| 22 |
+
# ----------------------------
|
| 23 |
+
# Simple in-memory "database"
|
| 24 |
+
# ----------------------------
|
| 25 |
+
users = {}
|
| 26 |
+
|
| 27 |
+
@app.route("/")
|
| 28 |
+
def home():
|
| 29 |
+
if "user" in session:
|
| 30 |
+
return redirect(url_for("dashboard"))
|
| 31 |
+
return redirect(url_for("login"))
|
| 32 |
+
|
| 33 |
+
@app.route("/signup", methods=["GET", "POST"])
|
| 34 |
+
def signup():
|
| 35 |
+
if request.method == "POST":
|
| 36 |
+
username = request.form["username"]
|
| 37 |
+
password = request.form["password"]
|
| 38 |
+
confirm_password = request.form.get("confirmPassword")
|
| 39 |
+
|
| 40 |
+
if password != confirm_password:
|
| 41 |
+
flash("Passwords do not match.", "danger")
|
| 42 |
+
return redirect(url_for("signup"))
|
| 43 |
+
|
| 44 |
+
if username in users:
|
| 45 |
+
flash("Username already exists!", "danger")
|
| 46 |
+
return redirect(url_for("signup"))
|
| 47 |
+
|
| 48 |
+
users[username] = generate_password_hash(password)
|
| 49 |
+
flash("Signup successful! Please login.", "success")
|
| 50 |
+
return redirect(url_for("login"))
|
| 51 |
+
|
| 52 |
+
return render_template("signup.html")
|
| 53 |
+
|
| 54 |
+
@app.route("/login", methods=["GET", "POST"])
|
| 55 |
+
def login():
|
| 56 |
+
if request.method == "POST":
|
| 57 |
+
username = request.form["username"]
|
| 58 |
+
password = request.form["password"]
|
| 59 |
+
|
| 60 |
+
if username in users and check_password_hash(users[username], password):
|
| 61 |
+
session["user"] = username
|
| 62 |
+
return redirect(url_for("dashboard"))
|
| 63 |
+
else:
|
| 64 |
+
flash("Invalid username or password", "danger")
|
| 65 |
+
|
| 66 |
+
return render_template("login.html")
|
| 67 |
+
|
| 68 |
+
@app.route("/dashboard")
|
| 69 |
+
def dashboard():
|
| 70 |
+
if "user" not in session:
|
| 71 |
+
return redirect(url_for("login"))
|
| 72 |
+
return render_template("dashboard.html", username=session["user"])
|
| 73 |
+
|
| 74 |
+
@app.route("/predict", methods=["POST"])
|
| 75 |
+
def predict():
|
| 76 |
+
if "user" not in session:
|
| 77 |
+
return redirect(url_for("login"))
|
| 78 |
+
|
| 79 |
+
try:
|
| 80 |
+
sl = float(request.form["sepal_length"])
|
| 81 |
+
sw = float(request.form["sepal_width"])
|
| 82 |
+
pl = float(request.form["petal_length"])
|
| 83 |
+
pw = float(request.form["petal_width"])
|
| 84 |
+
except Exception:
|
| 85 |
+
flash("Invalid input values!", "danger")
|
| 86 |
+
return redirect(url_for("dashboard"))
|
| 87 |
+
|
| 88 |
+
res = iris_model.predict([[sl, sw, pl, pw]])[0]
|
| 89 |
+
flash(f"The predicted flower species is: {res}", "success")
|
| 90 |
+
return redirect(url_for("dashboard"))
|
| 91 |
+
|
| 92 |
+
@app.route("/portfolio")
|
| 93 |
+
def portfolio():
|
| 94 |
+
if "user" not in session:
|
| 95 |
+
return redirect(url_for("login"))
|
| 96 |
+
return render_template("portfolio.html")
|
| 97 |
+
|
| 98 |
+
@app.route("/logout")
|
| 99 |
+
def logout():
|
| 100 |
+
session.pop("user", None)
|
| 101 |
+
flash("Logged out successfully.", "info")
|
| 102 |
+
return redirect(url_for("login"))
|
| 103 |
+
|
| 104 |
+
if __name__ == "__main__":
|
| 105 |
+
app.run(host="0.0.0.0", port=7860, debug=True)
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
flask
|
| 2 |
+
werkzeug
|
| 3 |
+
seaborn
|
| 4 |
+
scikit-learn
|
| 5 |
+
numpy
|
static/style.css
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* Basic reset */
|
| 2 |
+
* { box-sizing: border-box; }
|
| 3 |
+
|
| 4 |
+
body {
|
| 5 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 6 |
+
background: linear-gradient(135deg, #6b73ff, #000dff);
|
| 7 |
+
height: 100vh;
|
| 8 |
+
margin: 0;
|
| 9 |
+
display: flex;
|
| 10 |
+
justify-content: center;
|
| 11 |
+
align-items: center;
|
| 12 |
+
color: #fff;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
.container {
|
| 16 |
+
background: rgba(255, 255, 255, 0.1);
|
| 17 |
+
padding: 30px 40px;
|
| 18 |
+
border-radius: 15px;
|
| 19 |
+
width: 100%;
|
| 20 |
+
max-width: 400px;
|
| 21 |
+
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
|
| 22 |
+
backdrop-filter: blur(8px);
|
| 23 |
+
-webkit-backdrop-filter: blur(8px);
|
| 24 |
+
border: 1px solid rgba(255, 255, 255, 0.18);
|
| 25 |
+
text-align: center;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
h2 {
|
| 29 |
+
margin-bottom: 25px;
|
| 30 |
+
font-weight: 700;
|
| 31 |
+
letter-spacing: 1px;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
input {
|
| 35 |
+
width: 100%;
|
| 36 |
+
padding: 12px 15px;
|
| 37 |
+
margin: 10px 0;
|
| 38 |
+
border-radius: 8px;
|
| 39 |
+
border: none;
|
| 40 |
+
outline: none;
|
| 41 |
+
font-size: 16px;
|
| 42 |
+
transition: background-color 0.3s ease;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
input:focus { background-color: rgba(255, 255, 255, 0.2); }
|
| 46 |
+
|
| 47 |
+
button {
|
| 48 |
+
width: 100%;
|
| 49 |
+
padding: 12px 15px;
|
| 50 |
+
margin-top: 15px;
|
| 51 |
+
background-color: #3a3cff;
|
| 52 |
+
border: none;
|
| 53 |
+
border-radius: 8px;
|
| 54 |
+
color: white;
|
| 55 |
+
font-weight: 600;
|
| 56 |
+
font-size: 18px;
|
| 57 |
+
cursor: pointer;
|
| 58 |
+
transition: background-color 0.3s ease;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
button:hover { background-color: #2222ff; }
|
| 62 |
+
|
| 63 |
+
#signupMessage, #loginMessage {
|
| 64 |
+
margin-top: 15px;
|
| 65 |
+
font-weight: 600;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
.switch-page {
|
| 69 |
+
margin-top: 20px;
|
| 70 |
+
font-size: 14px;
|
| 71 |
+
color: #ddd;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
.switch-page a {
|
| 75 |
+
color: #a6c1ff;
|
| 76 |
+
text-decoration: none;
|
| 77 |
+
font-weight: 600;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
.switch-page a:hover { text-decoration: underline; }
|
templates/base.html
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Flask Auth + Portfolio</title>
|
| 7 |
+
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
| 8 |
+
</head>
|
| 9 |
+
<body>
|
| 10 |
+
{% with messages = get_flashed_messages(with_categories=true) %}
|
| 11 |
+
{% if messages %}
|
| 12 |
+
<ul>
|
| 13 |
+
{% for category, message in messages %}
|
| 14 |
+
<li class="{{ category }}">{{ message }}</li>
|
| 15 |
+
{% endfor %}
|
| 16 |
+
</ul>
|
| 17 |
+
{% endif %}
|
| 18 |
+
{% endwith %}
|
| 19 |
+
{% block content %}{% endblock %}
|
| 20 |
+
</body>
|
| 21 |
+
</html>
|
templates/dashboard.html
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% extends "base.html" %}
|
| 2 |
+
{% block content %}
|
| 3 |
+
<div class="container" role="main">
|
| 4 |
+
<header class="profile-header">
|
| 5 |
+
<h1 id="fullName">{{ username }}</h1>
|
| 6 |
+
<h2 id="title">Student</h2>
|
| 7 |
+
</header>
|
| 8 |
+
|
| 9 |
+
<section aria-labelledby="about-me-title">
|
| 10 |
+
<h3 id="about-me-title">About Me</h3>
|
| 11 |
+
<p>
|
| 12 |
+
I am a motivated student actively learning Python, artificial intelligence, machine learning,
|
| 13 |
+
and web development. Driven by curiosity and innovation, I strive to create impactful solutions
|
| 14 |
+
and grow my expertise in these cutting-edge technologies.
|
| 15 |
+
</p>
|
| 16 |
+
</section>
|
| 17 |
+
|
| 18 |
+
<section aria-labelledby="skills-title">
|
| 19 |
+
<h3 id="skills-title">Skills</h3>
|
| 20 |
+
<ul class="skills-list">
|
| 21 |
+
<li>Python</li>
|
| 22 |
+
<li>Artificial Intelligence (AI)</li>
|
| 23 |
+
<li>Machine Learning (ML)</li>
|
| 24 |
+
<li>Web Development (HTML, CSS, JavaScript)</li>
|
| 25 |
+
<li>Data Analysis</li>
|
| 26 |
+
<li>Flask / Django</li>
|
| 27 |
+
<li>RESTful APIs</li>
|
| 28 |
+
<li>Git & Version Control</li>
|
| 29 |
+
</ul>
|
| 30 |
+
</section>
|
| 31 |
+
|
| 32 |
+
<section aria-labelledby="projects-title">
|
| 33 |
+
<h3 id="projects-title">Projects</h3>
|
| 34 |
+
<div class="projects">
|
| 35 |
+
<article class="project-card">
|
| 36 |
+
<h4>NumPy Project</h4>
|
| 37 |
+
<p>A hands-on project utilizing NumPy for efficient numerical computations and data manipulation.</p>
|
| 38 |
+
<a href="#" target="_blank" rel="noopener noreferrer">Project Link</a>
|
| 39 |
+
</article>
|
| 40 |
+
|
| 41 |
+
<article class="project-card">
|
| 42 |
+
<h4>Data Visualization Project</h4>
|
| 43 |
+
<p>Created dynamic visual representations of data using Matplotlib and Seaborn to uncover insights.</p>
|
| 44 |
+
<a href="#" target="_blank" rel="noopener noreferrer">Project Link</a>
|
| 45 |
+
</article>
|
| 46 |
+
</div>
|
| 47 |
+
</section>
|
| 48 |
+
|
| 49 |
+
<!-- 🔹 Iris Prediction Form -->
|
| 50 |
+
<section aria-labelledby="predict-title">
|
| 51 |
+
<h3 id="predict-title">Iris Flower Predictor</h3>
|
| 52 |
+
<form method="POST" action="{{ url_for('predict') }}">
|
| 53 |
+
<input type="number" step="0.1" name="sepal_length" placeholder="Sepal Length" required>
|
| 54 |
+
<input type="number" step="0.1" name="sepal_width" placeholder="Sepal Width" required>
|
| 55 |
+
<input type="number" step="0.1" name="petal_length" placeholder="Petal Length" required>
|
| 56 |
+
<input type="number" step="0.1" name="petal_width" placeholder="Petal Width" required>
|
| 57 |
+
<button type="submit">Predict</button>
|
| 58 |
+
</form>
|
| 59 |
+
</section>
|
| 60 |
+
|
| 61 |
+
<section class="contact">
|
| 62 |
+
<a href="https://linkedin.com/in/gursimar007" target="_blank" rel="noopener noreferrer">LinkedIn</a>
|
| 63 |
+
<a href="https://github.com/gursimar007" target="_blank" rel="noopener noreferrer">GitHub</a>
|
| 64 |
+
</section>
|
| 65 |
+
|
| 66 |
+
<a href="{{ url_for('logout') }}">
|
| 67 |
+
<button class="logout-btn">Logout</button>
|
| 68 |
+
</a>
|
| 69 |
+
</div>
|
| 70 |
+
{% endblock %}
|
templates/login.html
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% extends "base.html" %}
|
| 2 |
+
{% block content %}
|
| 3 |
+
<div class="container">
|
| 4 |
+
<h2>Sign In</h2>
|
| 5 |
+
<form method="POST" id="loginForm">
|
| 6 |
+
<input type="text" name="username" id="loginUsername" placeholder="Username" required />
|
| 7 |
+
<input type="password" name="password" id="loginPassword" placeholder="Password" required />
|
| 8 |
+
<button type="submit">Login</button>
|
| 9 |
+
</form>
|
| 10 |
+
<p id="loginMessage"></p>
|
| 11 |
+
<p class="switch-page">
|
| 12 |
+
Don't have an account? <a href="{{ url_for('signup') }}">Sign up here</a>
|
| 13 |
+
</p>
|
| 14 |
+
</div>
|
| 15 |
+
{% endblock %}
|
templates/portfolio.html
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% extends "base.html" %}
|
| 2 |
+
{% block content %}
|
| 3 |
+
<div class="container">
|
| 4 |
+
<h2>My Portfolio</h2>
|
| 5 |
+
<p>Here you can showcase your projects, images, or links.</p>
|
| 6 |
+
<ul>
|
| 7 |
+
<li><a href="https://github.com/yourname" target="_blank">GitHub</a></li>
|
| 8 |
+
<li><a href="https://linkedin.com/in/yourname" target="_blank">LinkedIn</a></li>
|
| 9 |
+
</ul>
|
| 10 |
+
</div>
|
| 11 |
+
{% endblock %}
|
templates/signup.html
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{% extends "base.html" %}
|
| 2 |
+
{% block content %}
|
| 3 |
+
<div class="container">
|
| 4 |
+
<h2>Create Account</h2>
|
| 5 |
+
<form method="POST" id="signupForm">
|
| 6 |
+
<input type="text" name="username" id="newUsername" placeholder="Username" required />
|
| 7 |
+
<input type="password" name="password" id="newPassword" placeholder="Password" required />
|
| 8 |
+
<input type="password" name="confirmPassword" id="confirmPassword" placeholder="Confirm Password" required />
|
| 9 |
+
<button type="submit">Sign Up</button>
|
| 10 |
+
</form>
|
| 11 |
+
<p id="signupMessage"></p>
|
| 12 |
+
<p class="switch-page">
|
| 13 |
+
Already have an account? <a href="{{ url_for('login') }}">Login here</a>
|
| 14 |
+
</p>
|
| 15 |
+
</div>
|
| 16 |
+
{% endblock %}
|