0% found this document useful (0 votes)
3 views

Copy of COMPUTER SCIENC PROJECT BADARISH

This document outlines a computer science project by Raja Murugesan, detailing the use of Python and MySQL for software development. It includes sections on project requirements, coding examples, and features of both programming languages, along with acknowledgments and a bonafide certificate. The project aims to implement an admin panel and user management functionalities, showcasing practical applications of the technologies discussed.
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)
3 views

Copy of COMPUTER SCIENC PROJECT BADARISH

This document outlines a computer science project by Raja Murugesan, detailing the use of Python and MySQL for software development. It includes sections on project requirements, coding examples, and features of both programming languages, along with acknowledgments and a bonafide certificate. The project aims to implement an admin panel and user management functionalities, showcasing practical applications of the technologies discussed.
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
You are on page 1/ 27

COMPUTER

SCIENCE
PROJECT
TABLE OF CONTENTS

1. BONAFIDE CERTIFICATE

2. ACKNOWLEDGEMENT

3. INTRODUCTION

4. ABOUT PYTHON

5. ABOUT MYSQL

6.REQUIRMENTS OF PROJECT

7. CODING

8. BIBLIOGRAPHY
Bonafide Certificate
Register No. Internal Assessment

Certified to be the Bonafide Project Work in Computer Science done by


RAJA MURUGESAN R of Class XII, Section ‘C’ of DAV Boys Senior
Secondary School, Gopalapuram during the year 2024 to 2025.

Signature of Principal Signature of the subject teacher


Designation(PGT/ TGT)
School Seal

Submitted for the practical examination held

on

at

Internal Examiner External Examiner

Chief Superintendent

Date:
ACKNOWLEDGEMENT

I would like to express my special thanks of gratitude


to our principal Mrs. Swarna Prabhakaran for
providing me with all required facilities. Secondly, I
would like to extend my gratitude to my computer
science teacher, Mrs. Hemalatha for her guidance
and support in completing the project. I would also
like to thank my parents who helped me in
completing this project within the specified time.
ABOUT PYTHON

Introduction

It is widely used general purpose, high


level programming language.
Developed by Guido van rossum in 1991.
It is used for: software development, web
development (server-side), system scripting,
Mathematics.

Features of python

1. Easy to use : Due to simple syntax rule


2. Interpreted language : code execution &
interpretation line by line.
3. Cross-Platform language : it can run on
windows, linux, Macinetosh etc. equally
4. Expressive language: less code to be
written as it itself express the purpose of the
code.
5. Completeness: Supports wide range of
library.
6. Free & Open source : can be downloaded
freely and source code can be Modify for
improvement.

Advantages of Kotlin:
Concise and expressive syntax: Reduces
boilerplate code, making the codebase
cleaner and easier to maintain.
Null safety: Helps avoid common issues
like NullPointerExceptions with features
like safe calls (?.) and the Elvis operator
(?:).
Interoperability with Java: Fully
compatible with Java, allowing easy
integration with existing Java libraries and
projects.
Coroutines for asynchronous
programming: Simplifies managing
concurrency and asynchronous tasks
compared to traditional threading
models.
Smart casts: Automatically casts types
after a type check, reducing the need for
explicit casting.
Extension functions: Lets you add new
functionality to existing classes without
modifying their source code.
Improved tooling support: Excellent IDE
support (IntelliJ IDEA, Android Studio)
with features like code completion,
refactoring, and debugging.

Drawbacks of python

1. Lesser libraries : As compared to other


programming languages like c++,java,.net etc.
2. Slow Language: As it is interpreted
languages,it executes the program slowly.
3. Weak on type-binding : it not pin point on
use of a single variable for different data
type.
Disadvantages of Kotlin:
Slower compilation time: Kotlin’s
compilation can be slower than Java,
which can impact build times in large
projects.
Smaller ecosystem: Fewer libraries and a
smaller community compared to Java,
which may make it harder to find
solutions for niche use cases.
Learning curve: Developers transitioning
from Java may find advanced Kotlin
features (e.g., coroutines, extension
functions) challenging at first.
Runtime exceptions with !!: Using the not-
null assertion operator (!!) improperly can
lead to NullPointerExceptions, defeating
the language's safety features.
Less mature in some areas: Kotlin’s cross-
platform development (Kotlin
Multiplatform) is still evolving and lacks
some of the maturity of other cross-
platform tools.
ABOUT MYSQL

Introduction

MySQL is currently the Most popular open


source database software. It is a Multi-user,
Multithreaded database Management system.
MySQL is especially popular on the web. it
is one of the parts of the very popular
platform such as linux, windows etc.
MySQL was founded by Michael Widenius
(Monty), David AxMarK and Allan Larsson in
sweden in year 1995.

Features of MySQL:

Open source & free of cost: it is open


source and available at free of cost.
Portability: Small enough in size to install
and run it on any types of hardware and
OS like linux, MS windows or Mac etc.
Security: Its databases are
secured & Protected with
password.
Connectivity : various apps are
developed to connect it with
many programming languages.
Query language: It supports SQL
(Structured Query language) for
handling database.

REQUIREMENTS:
Hardware Requirements:
1. Computer:For coding and typing
the required Documents of the
project.
2. Printer: To print the required
documents of the Project.
3. Compact Drive.
4.Processor : Pentium Quad core
5.RAM : 64 Mb
6.Hard Disk : 20 gb
Software requirements:
1. Operating system : Windows 7 or
above
2. MySQL : for storing data in the
database
3. Python: mysql connector; for
database Connectivity
4. android studio :apk instalation
5. Microsoft Word: for documentation.
Scopes of Improvement
1. Admin Panel Implementation (HTML Frontend)
User Management:
Allow admins to view, edit, and delete user profiles.
Implement role-based access control (RBAC) to distinguish between admin and regular users.
Content Management:
Enable admins to add, edit, and delete content such as posts, comments, etc.
Implement CRUD operations (Create, Read, Update, Delete) for managing content via the admin panel.
Data Visualization:
Display charts and graphs to visualize user activity and content performance using tools like Chart.js or
Plotly.
Include key metrics like total users, active users, posts, etc.
Search and Filtering:
Allow admins to search and filter users, posts, and other content based on parameters like date, status, or
category.
Activity Logs:
Maintain audit logs of admin actions such as content editing, user changes, etc., for security and monitoring
purposes.
Admin Authentication:
Secure the admin panel with admin-specific authentication using JWT tokens or session-based
authentication.
Frontend (HTML/CSS/JS):
Use modern frontend libraries like Bootstrap or Tailwind CSS to create a clean, responsive UI for the admin
panel.
Implement AJAX for real-time data interaction and updates without page reloads.
2. Remarks Feature on the Frontend
Adding Remarks to Content:
Enable users or admins to add remarks or comments to specific content, such as posts or articles.
Real-time Updates:
Use AJAX or WebSockets to allow dynamic updates to remarks, enabling real-time interaction without
refreshing the page.
OUTPUTS:
CODING

package com.example.dav

import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import com.example.dav.*
import com.example.dav.models.*
class LoginActivity : AppCompatActivity() {

private lateinit var emailEditText: EditText


private lateinit var passwordEditText: EditText
private lateinit var loginButton: Button
private lateinit var forgotPasswordText: TextView

override fun onCreate(savedInstanceState: Bundle?) {


super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)

emailEditText = findViewById(R.id.emailEditText)
passwordEditText = findViewById(R.id.passwordEditText)
loginButton = findViewById(R.id.loginButton)
forgotPasswordText = findViewById(R.id.forgotPasswordButton)

loginButton.setOnClickListener {
val email = emailEditText.text.toString()
val password = passwordEditText.text.toString()

if (email.isNotEmpty() && password.isNotEmpty()) {


login(email, password)
} else {
Toast.makeText(this, "Please fill in all fields", Toast.LENGTH_SHORT).show()
}
}

forgotPasswordText.setOnClickListener {
val email = emailEditText.text.toString()

if (email.isNotEmpty()) {
sendForgotPasswordRequest(email)
} else {
Toast.makeText(this, "Please enter your email", Toast.LENGTH_SHORT).show()
}
}
}
private fun login(email: String, password: String) {
CoroutineScope(Dispatchers.IO).launch {
try {
val response = RetrofitClient.apiService.login(LoginRequest(email, password))
if (response.isSuccessful) {
val token = response.body()?.accessToken
val intent = Intent(this@LoginActivity, ProfileActivity::class.java)
intent.putExtra("TOKEN", token)
startActivity(intent)
} else {
runOnUiThread {
Toast.makeText(this@LoginActivity, "Invalid login credentials", Toast.LENGTH_SHORT).show()
}
}
} catch (e: Exception) {
runOnUiThread {
Toast.makeText(this@LoginActivity, "Error: ${e.message}", Toast.LENGTH_SHORT).show()
}
}
}
}

private fun sendForgotPasswordRequest(email: String) {


CoroutineScope(Dispatchers.IO).launch {
try {
val response = RetrofitClient.apiService.forgotPassword(ForgotPasswordRequest(email))
if (response.isSuccessful) {
runOnUiThread {
Toast.makeText(this@LoginActivity, "Password reset email sent", Toast.LENGTH_SHORT).show()
}
} else {
runOnUiThread {
Toast.makeText(this@LoginActivity, "Failed to send reset email", Toast.LENGTH_SHORT).show()
}
}
} catch (e: Exception) {
runOnUiThread {
Toast.makeText(this@LoginActivity, "Error: ${e.message}", Toast.LENGTH_SHORT).show()
}
}
}
}
}
package com.example.dav

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity

class MainActivity : AppCompatActivity() {


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val intent = Intent(this, LoginActivity::class.java)
startActivity(intent)
finish()
}
}

package com.example.dav

import android.os.Bundle
import android.widget.ImageView
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.squareup.picasso.Picasso
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

class ProfileActivity : AppCompatActivity() {

private lateinit var profileImageView: ImageView


private lateinit var nameTextView: TextView
private lateinit var admissionNoTextView: TextView
private lateinit var classTextView: TextView
private lateinit var sectionTextView: TextView
private lateinit var genderTextView: TextView
private lateinit var communicationNoTextView: TextView
private lateinit var communicationEmailTextView: TextView
private lateinit var bloodGroupTextView: TextView

override fun onCreate(savedInstanceState: Bundle?) {


super.onCreate(savedInstanceState)
setContentView(R.layout.activity_profile)

profileImageView = findViewById(R.id.profileImageView)
nameTextView = findViewById(R.id.nameTextView)
admissionNoTextView = findViewById(R.id.admissionNoTextView)
classTextView = findViewById(R.id.classTextView)
sectionTextView = findViewById(R.id.sectionTextView)
genderTextView = findViewById(R.id.genderTextView)
communicationNoTextView = findViewById(R.id.communicationNoTextView)
communicationEmailTextView = findViewById(R.id.communicationEmailTextView)
bloodGroupTextView = findViewById(R.id.bloodGroupTextView)

val token = intent.getStringExtra("TOKEN")


if (token != null) {
fetchProfile(token)
} else {
Toast.makeText(this, "Token is missing", Toast.LENGTH_SHORT).show()
}
}

private fun fetchProfile(token: String) {


CoroutineScope(Dispatchers.IO).launch {
try {
val response = RetrofitClient.apiService.getProfile("Bearer $token")
if (response.isSuccessful) {
val profile = response.body()
runOnUiThread {
nameTextView.text = profile?.name
admissionNoTextView.text = profile?.admissionNo
classTextView.text = profile?.class_
sectionTextView.text = profile?.section
genderTextView.text = profile?.gender
communicationNoTextView.text = profile?.communicationNo
communicationEmailTextView.text = profile?.communicationEmail
bloodGroupTextView.text = profile?.bloodGroup
Picasso.get().load(profile?.photoUrl).into(profileImageView)
}
} else {
runOnUiThread {
Toast.makeText(this@ProfileActivity, "Failed to fetch profile", Toast.LENGTH_SHORT).show()
}
}
} catch (e: Exception) {
runOnUiThread {
Toast.makeText(this@ProfileActivity, "Error: ${e.message}", Toast.LENGTH_SHORT).show()
}
}
}
}
}
package com.example.dav

import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

object RetrofitClient {
private const val BASE_URL = "https://apps-git-main-raja986s-
projects.vercel.app/"

private val client = OkHttpClient.Builder().build()

val apiService: ApiService = Retrofit.Builder()


.baseUrl(BASE_URL)
.client(client)
.addConverterFactory(GsonConverterFactory.create())
.build()
.create(ApiService::class.java)
}
package com.example.dav
import retrofit2.Response
import retrofit2.http.*
import com.example.dav.models.*
interface ApiService {
@POST("login")
suspend fun login(@Body request: LoginRequest): Response<LoginResponse>

@POST("forgot-password")
suspend fun forgotPassword(@Body request: ForgotPasswordRequest):
Response<ForgotPasswordResponse>

@GET("profile")
suspend fun getProfile(@Header("Authorization") token: String): Response<StudentProfile>
}

package com.example.dav.models
data class ForgotPasswordRequest(
val email: String
)
package com.example.dav.models

data class ForgotPasswordResponse(


val message: String
)

package com.example.dav.models

data class LoginCredentials(


val email: String,
val password: String
)
package com.example.dav.models

data class LoginRequest(


val email: String,
val password: String
)
package com.example.dav.models

data class LoginResponse(


val accessToken: String
)
package com.example.dav.models

data class StudentProfile(


val name: String,
val admissionNo: String,
val class_: String,
val section: String,
val gender: String,
val communicationNo: String,
val communicationEmail: String,
val bloodGroup: String,
val height: Float?,
val weight: Float?,
val identificationMark: String?,
val nationality: String?,
val religion: String?,
val photoUrl: String
)
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp"
android:gravity="center">

<ImageView
android:id="@+id/logoImageView"
android:layout_width="217dp"
android:layout_height="233dp"
android:layout_gravity="center"
android:scaleType="centerCrop"
android:src="@drawable/logo" />

<EditText
android:id="@+id/emailEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
android:inputType="textEmailAddress"
android:padding="12dp"
android:layout_marginTop="16dp"
android:background="@drawable/edit_text_background"/>

<EditText
android:id="@+id/passwordEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword"
android:padding="12dp"
android:layout_marginTop="16dp"
android:background="@drawable/edit_text_background"/>

<Button
android:id="@+id/forgotPasswordButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Forgot Password?"
android:layout_marginTop="16dp"/>

<Button
android:id="@+id/loginButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Login"
android:layout_marginTop="16dp" />

</LinearLayout>
</ScrollView>
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<EditText
android:id="@+id/etEmail"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="Email"
android:inputType="textEmailAddress"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="100dp" />

<EditText
android:id="@+id/etPassword"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/etEmail"a
android:layout_marginTop="20dp" />

<Button
android:id="@+id/btnLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
app:layout_constraintTop_toBottomOf="@id/etPassword"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="40dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">

<!-- Profile Picture -->


<ImageView
android:id="@+id/profileImageView"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center"
android:layout_marginBottom="16dp"
android:scaleType="centerCrop"
android:src="@drawable/ic_launcher_background" />

<!-- Student Name -->


<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Name:"
android:textStyle="bold"
android:paddingTop="8dp"
android:textSize="16sp" />

<TextView
android:id="@+id/nameTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="16sp" />

<!-- Admission Number -->


<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Admission No:"
android:textStyle="bold"
android:paddingTop="8dp"
android:textSize="16sp" />

<TextView
android:id="@+id/admissionNoTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="16sp" />

<!-- Class -->


<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Class:"
android:textStyle="bold"
android:paddingTop="8dp"
android:textSize="16sp" />

<TextView
android:id="@+id/classTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="16sp" />
<!-- Section -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Section:"
android:textStyle="bold"
android:paddingTop="8dp"
android:textSize="16sp" />

<TextView
android:id="@+id/sectionTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="16sp" />

<!-- Gender -->


<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Gender:"
android:textStyle="bold"
android:paddingTop="8dp"
android:textSize="16sp" />

<TextView
android:id="@+id/genderTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="16sp" />

<!-- Communication Number -->


<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Communication No:"
android:textStyle="bold"
android:paddingTop="8dp"
android:textSize="16sp" />

<TextView
android:id="@+id/communicationNoTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="16sp" />

<!-- Communication Email -->


<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Communication Email:"
android:textStyle="bold"
android:paddingTop="8dp"
android:textSize="16sp" />

<TextView
android:id="@+id/communicationEmailTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="16sp" />

<!-- Blood Group -->


<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Blood Group:"
android:textStyle="bold"
android:paddingTop="8dp"
android:textSize="16sp" />

<TextView
android:id="@+id/bloodGroupTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="16sp" />

</LinearLayout>
</ScrollView>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">

<TextView
android:id="@+id/studentDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<EditText
android:id="@+id/editName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name"/>

<EditText
android:id="@+id/editParentsMobile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Parent's Mobile"/>

<EditText
android:id="@+id/editAddress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Address"/>

<Button
android:id="@+id/updateDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Update Details"/>
<Button
android:id="@+id/viewRemarks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="View Remarks" />

</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">

<EditText
android:id="@+id/studentName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Student Name"/>
<EditText
android:id="@+id/studentpass"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Student password"/>

<Button
android:id="@+id/addStudentButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add Student"/>

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/studentList"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</LinearLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="8dp">

<TextView
android:id="@+id/studentDetails"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="16sp" />

<Button
android:id="@+id/viewRemarksButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remarks" />

<Button
android:id="@+id/deleteStudentButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Delete" />
</LinearLayout>

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="8dp">

<TextView
android:id="@+id/teacherDetails"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="16sp" />

<Button
android:id="@+id/deleteTeacherButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Delete" />
</LinearLayout>
PYTHON FILE
from flask import Flask, request, jsonify
from flask_jwt_extended import JWTManager, jwt_required, create_access_token, get_jwt_identity
import mysql.connector
import hashlib
import smtplib

app = Flask(__name__)
app.config['JWT_SECRET_KEY'] = 'your_jwt_secret_key'
jwt = JWTManager(app)

db = mysql.connector.connect(
host="your_mysql_host",
user="your_mysql_user",
password="your_mysql_password",
database="your_database"
)
cursor = db.cursor()

@app.route('/login', methods=['POST'])
def login():
data = request.get_json()
email = data['email']
password = hashlib.sha256(data['password'].encode()).hexdigest()
cursor.execute("SELECT email FROM students WHERE email=%s AND password=%s", (email, password))
student = cursor.fetchone()
if student:
access_token = create_access_token(identity=email)
return jsonify({'access_token': access_token})
return jsonify({'message': 'Invalid email or password'}), 401

@app.route('/profile', methods=['GET'])
@jwt_required()
def profile():
email = get_jwt_identity()
cursor.execute("SELECT name, admission_no, class, section, gender, communication_no,
communication_email, blood_group, height, weight, identification_mark, nationality, religion, photo_url FROM
students WHERE email=%s", (email,))
student = cursor.fetchone()
if student:
fields = ['name', 'admission_no', 'class', 'section', 'gender', 'communication_no', 'communication_email',
'blood_group', 'height', 'weight', 'identification_mark', 'nationality', 'religion', 'photo_url']
return jsonify(dict(zip(fields, student)))
return jsonify({'message': 'Student not found'}), 404

@app.route('/forgot_password', methods=['POST'])
def forgot_password():
data = request.get_json()
email = data['email']
cursor.execute("SELECT email FROM students WHERE email=%s", (email,))
student = cursor.fetchone()
if student:
new_password = "NewPass123"
hashed_password = hashlib.sha256(new_password.encode()).hexdigest()
cursor.execute("UPDATE students SET password=%s WHERE email=%s", (hashed_password, email))
db.commit()
server = smtplib.SMTP('smtp.example.com', 587)
server.starttls()
server.login('[email protected]', 'your_email_password')
message = f"Subject: Password Reset\n\nYour new password is {new_password}"
server.sendmail('[email protected]', email, message)
server.quit()
return jsonify({'message': 'New password sent to email'})
return jsonify({'message': 'Email not found'}), 404
@app.route('/announcements', methods=['GET'])
@jwt_required()
def announcements():
cursor.execute("SELECT title, description, date FROM announcements ORDER BY date DESC")
announcements = cursor.fetchall()
return jsonify([{'title': row[0], 'description': row[1], 'date': row[2]} for row in announcements])

@app.route('/remarks', methods=['GET'])
@jwt_required()
def remarks():
email = get_jwt_identity()
cursor.execute("SELECT teacher_name, remark, date FROM remarks WHERE student_email=%s ORDER BY
date DESC", (email,))
remarks = cursor.fetchall()
return jsonify([{'teacher_name': row[0], 'remark': row[1], 'date': row[2]} for row in remarks])

if __name__ == '__main__':
app.run(debug=True)
BIBLIOGRAPHY

https://www.rcyber.tech
udemy
kavitha.guru

THANK
YOU

You might also like