Copy of COMPUTER SCIENC PROJECT BADARISH
Copy of COMPUTER SCIENC PROJECT BADARISH
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
on
at
Chief Superintendent
Date:
ACKNOWLEDGEMENT
Introduction
Features of python
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
Introduction
Features of MySQL:
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() {
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()
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()
}
}
}
}
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
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
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)
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/"
@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
package com.example.dav.models
<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">
<TextView
android:id="@+id/nameTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="16sp" />
<TextView
android:id="@+id/admissionNoTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
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" />
<TextView
android:id="@+id/genderTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="16sp" />
<TextView
android:id="@+id/communicationNoTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="16sp" />
<TextView
android:id="@+id/communicationEmailTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""
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