0% found this document useful (0 votes)
2 views7 pages

Skill Exchange

The Skill Exchange Platform is a web application developed using Flask and SQLite that connects mentors and learners. Users can register, add skills, request mentorship, and view other users and skills available on the platform. The application runs on port 8080 and utilizes Jinja2 templates for rendering content.

Uploaded by

soloqueen2009
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

Skill Exchange

The Skill Exchange Platform is a web application developed using Flask and SQLite that connects mentors and learners. Users can register, add skills, request mentorship, and view other users and skills available on the platform. The application runs on port 8080 and utilizes Jinja2 templates for rendering content.

Uploaded by

soloqueen2009
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

■ Skill Exchange Platform

A Flask + SQLite web application for connecting mentors and learners

■ Project Overview
Skill Exchange is a lightweight web application built with Flask (Python) and SQLite. It allows users to
register as mentors or learners, list skills they can teach or want to learn, and find matching mentors for
any requested skill. The app runs on port 8080 and uses Jinja2 templates for server-side rendering.

Feature Description

Register User Sign up as a Mentor or Learner with a display name

Add Skill Link a skill (teach/learn) to any registered user

Request Skill Search for mentors who can teach a desired skill

View Users Browse all registered users with their roles

View Skills Browse all distinct skills listed on the platform

■■ Application Screenshots

Home Page — Central navigation hub with cards for all major features
Add Skill — Select a user, enter skill name and whether they teach or want to learn

Register User — Enter full name and choose role: Mentor or Learner
Request a Skill — Find mentors who can teach a specified skill

All Skills — Table listing every distinct skill on the platform


All Users — Table showing registered users with colour-coded roles

■ Source Code — [Link]


The complete Flask application is a single Python file. It defines the SQLite schema, helper functions, and
all route handlers.

from flask import Flask, render_template, request


import sqlite3

app = Flask(__name__)
DB = "skill_exchange.db"

# Helper: get a database connection


def get_db():
conn = [Link](DB)
conn.row_factory = [Link] # access columns by name
return conn

# Setup: create tables on first run


def create_tables():
conn = get_db()
cursor = [Link]()
[Link]("""
CREATE TABLE IF NOT EXISTS Users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
role TEXT
)
""")
[Link]("""
CREATE TABLE IF NOT EXISTS Skills (
id INTEGER PRIMARY KEY AUTOINCREMENT,
skill_name TEXT
)
""")
[Link]("""
CREATE TABLE IF NOT EXISTS UserSkills (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER,
skill_name TEXT,
type TEXT
)
""")
[Link]()
[Link]()

# Home page
@[Link]("/")
def index():
return render_template("[Link]")

# Register user
@[Link]("/register", methods=["GET", "POST"])
def register():
message = ""
if [Link] == "POST":
name = [Link]["name"].strip()
role = [Link]["role"]
if name:
conn = get_db()
[Link](
"INSERT INTO Users (name, role) VALUES (?, ?)", (name, role)
)
[Link]()
[Link]()
message = f"User '{name}' registered successfully!"
else:
message = "Please enter a name."
return render_template("[Link]", message=message)

# Add skill
@[Link]("/add_skill", methods=["GET", "POST"])
def add_skill():
message = ""
conn = get_db()
users = [Link]("SELECT id, name FROM Users").fetchall()
[Link]()

if [Link] == "POST":
user_id = [Link]["user_id"]
skill_name = [Link]["skill_name"].strip()
skill_type = [Link]["skill_type"]
if skill_name:
conn = get_db()
[Link](
"INSERT INTO Skills (skill_name) VALUES (?)", (skill_name,)
)
[Link](
"INSERT INTO UserSkills (user_id, skill_name, type) "
"VALUES (?, ?, ?)",
(user_id, skill_name, skill_type)
)
[Link]()
[Link]()
message = f"Skill '{skill_name}' added!"
else:
message = "Please enter a skill name."
return render_template("add_skill.html", users=users, message=message)

# Request skill + show matching mentors


@[Link]("/request_skill", methods=["GET", "POST"])
def request_skill():
mentors = []
message = ""
skill_req = ""
conn = get_db()
users = [Link]("SELECT id, name FROM Users").fetchall()
[Link]()

if [Link] == "POST":
user_id = [Link]["user_id"]
skill_req = [Link]["skill_name"].strip()
if skill_req:
conn = get_db()
[Link](
"INSERT INTO UserSkills (user_id, skill_name, type) "
"VALUES (?, ?, 'learn')",
(user_id, skill_req)
)
[Link]()
rows = [Link](
"SELECT user_id FROM UserSkills "
"WHERE skill_name = ? AND type = 'teach'",
(skill_req,)
).fetchall()
for row in rows:
mentor = [Link](
"SELECT name FROM Users WHERE id = ?",
(row["user_id"],)
).fetchone()
if mentor:
[Link](
{"id": row["user_id"], "name": mentor["name"]}
)
[Link]()
message = f"Request saved! Mentors found for '{skill_req}':':"
if not mentors:
message = (
f"Request saved! No mentors found for '{skill_req}' yet."
)
else:
message = "Please enter a skill name."

return render_template(
"request_skill.html", users=users,
mentors=mentors, message=message, skill_req=skill_req
)

# View all users


@[Link]("/users")
def view_users():
conn = get_db()
users = [Link]("SELECT id, name, role FROM Users").fetchall()
[Link]()
return render_template("[Link]", users=users)

# View all skills


@[Link]("/skills")
def view_skills():
conn = get_db()
skills = [Link]("SELECT id, skill_name FROM Skills").fetchall()
[Link]()
return render_template("[Link]", skills=skills)

# Run the app


if __name__ == "__main__":
create_tables()
print("Server running at: [Link]
[Link](host="[Link]", port=8080, debug=True)

■■ Database Schema
Table Column Type Notes

id INTEGER PK Auto-incremented

Users name TEXT User's display name

role TEXT 'mentor' or 'learner'

id INTEGER PK Auto-incremented
Skills
skill_name TEXT Distinct skill label

id INTEGER PK Auto-incremented

user_id INTEGER FK References [Link]


UserSkills
skill_name TEXT Denormalised skill name

type TEXT 'teach' or 'learn'

Skill Exchange Platform · Flask + SQLite · Port 8080

You might also like