Skip to content

Commit

Permalink
Merge branch 'main' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
JSuhas123 authored Jul 6, 2024
2 parents 0a4d94f + cba2226 commit 2114632
Show file tree
Hide file tree
Showing 51 changed files with 3,345 additions and 497 deletions.
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"git.ignoreLimitWarning": true,
"liveServer.settings.port": 5501
}
86 changes: 86 additions & 0 deletions Contact us/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
*{
margin: 0;
padding: 0;
font-family: 'poppins', sans-serif;
box-sizing: border-box;
}
html{
scroll-behavior: smooth;
}
body{
background: lightcyan;
color: black;
}

.contact-left{
flex-basis: 35%;
padding: 20px;
}
.contact-right{
flex-basis: 60%;
padding: 20px;
}
.contact-left p{
margin-top: 30px;
}
.contact-left p i{
color: #ff004f;
margin-right: 15px;
font-size: 25px;
}
.social-icon{
margin-top: 30px;
}
.social-icon a{
text-decoration: none;
font-size: 30px;
margin-right: 15px;
color: blue;
display: inline-block;
transition: transform 0.5s;
}
.social-icon a:hover{
color: yellowgreen;
transform: translateY(-5px);
}
.btn.btn2{
display: inline-block;
background: blueviolet;
border-radius: 14px;
color: white;
}
.btn.btn2:hover{
background-color: #ff004f;
}

.contact-right form{
width: 100%;
}
form input, form textarea{
width: 100%;
border: 0;
outline: none;
background: rgb(232, 210, 238);
padding: 15px;
margin: 15px 0;
color: #fff;
font-size: 18px;
border-radius: 6px;
}
form .btn2{
padding: 14px 60px;
font-size: 18px;
margin-top: 20px;
cursor: pointer;
}
.copyright{
width: 100%;
text-align: center;
padding: 25px 0;
background: #262626;
font-weight: 300;
margin-top: 20px;
}
.copyright i{
color: #ff004f;
}
72 changes: 72 additions & 0 deletions DBSetup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@

# Check if python/python3 is installed
if (!(Get-Command python3 -ErrorAction SilentlyContinue)) {
Write-Host "Python3 is not installed."
exit 1
}
else {
if (!(python --version 2>&1 | Out-Null)) {
python3 --version
}
else {
python --version
}
}


# Check if pip/pip3 is installed
$pipInstalled = $false
$pip3Installed = $false

if (Get-Command pip -ErrorAction SilentlyContinue) {
pip --version
$pipInstalled = $true
Write-Host ""
}
else {
$pipInstalled = $false
}

if (Get-Command pip3 -ErrorAction SilentlyContinue) {
pip3 --version
$pip3Installed = $true
Write-Host ""
}
else {
$pip3Installed = $false
}

if (!($pipInstalled -or $pip3Installed)) {
Write-Host "Neither pip nor pip3 is installed. Please install pip or pip3." -ForegroundColor Red
exit 1
}


# Move to Setup Directory
Set-Location -Path .\DBSetup


# Install modules using pip
if (pip install -r .\requirements.txt) {
Write-Host "`nRequired Modules Installed Success Fully...`n" -ForegroundColor Green
sleep 2
}
else {
Write-Host "`nFailed to install modules.`n" -ForegroundColor Red
sleep 2
}


# Try running python script
& python ./setup.py
if ($LASTEXITCODE -eq 0) {
Write-Host "Setup Script Successfully Exited with 0 errors.`n" -ForegroundColor Green
} else {
Write-Host "Python script failed." -ForegroundColor Red
}


Set-Location -Path ..
sleep 3


16 changes: 16 additions & 0 deletions DBSetup/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
##########################################
# REQUIREMENTS #
##########################################


# -------- Setup Operations -------- #
colorama
keyboard

# ---------- Database Connection ---------- #
mysql-connector-python


########################################################
# Install using: pip install -r requirements.txt #
########################################################
159 changes: 159 additions & 0 deletions DBSetup/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# Import Modules
import sys
import time
import keyboard
import mysql.connector as mys
from colorama import Fore


# Define ANSI escape codes for colors
COLORS = {
'white': '\033[37m',
'grey': '\033[90m',
'reset': '\033[0m'
}

# Define the options
OPTIONS = [
"Setup database from scratch",
"Re-setup the database",
"Exit Setup"
]


# Function to print the menu with arrow key selection
def print_menu(selected_index):
print("\033[1mSelect an option:\033[0m\n")
for index, option in enumerate(OPTIONS):
if index == selected_index:
print(f" {COLORS['white']}>> {option}{COLORS['reset']}")
else:
print(f" {COLORS['grey']}{option}{COLORS['reset']}")
print("\nUse the arrow keys (↓↑) to navigate and press Enter to select an option.")


def main():
selected_index = 0
while True:
sys.stdout.write("\033[H\033[J")
print_menu(selected_index)
key = keyboard.read_event()
if key.event_type == keyboard.KEY_DOWN:
if key.name == 'up':
selected_index = (selected_index - 1) % len(OPTIONS)
elif key.name == 'down':
selected_index = (selected_index + 1) % len(OPTIONS)
elif key.name == 'enter':
break

sys.stdout.write("\033[H\033[J")

selected_option = OPTIONS[selected_index]
if selected_option == "Setup database from scratch":
setup_database_from_scratch()
elif selected_option == "Re-setup the database":
reset_database()
elif selected_option == "Exit Setup":
print(Fore.MAGENTA + "Exiting Setup...\n\n" + Fore.RESET)
time.sleep(1)
sys.exit(0)


# Placeholder function for setting up database from scratch
def setup_database_from_scratch():
print(Fore.YELLOW + "\nSetting up database from scratch...\n" + Fore.RESET)

if passwd != "":
db_config = {
'user': 'root',
'host': 'localhost',
'password': passwd
}
else:
db_config = {
'user': 'root',
'host': 'localhost'
}

dbname = "carpool1"
table_name = "ride"

try:
conn = mys.connect(**db_config)
cursor = conn.cursor()
except:
print(Fore.RED + "Error: Could not connect to MySQL." + Fore.RESET)
time.sleep(1)
print(Fore.YELLOW + "Make sure MySQL is running and the credentials are correct.\n" + Fore.RESET)
time.sleep(3)
return

try:
cursor.execute(f"CREATE DATABASE IF NOT EXISTS {dbname}")
print(Fore.GREEN + f"Database '{dbname}' created successfully." + Fore.RESET)
except mys.Error as err:
print(Fore.RED + f"Error: {err}" + Fore.RESET)
return

conn.database = dbname
create_table_query = f"""
CREATE TABLE IF NOT EXISTS {table_name} (
nam VARCHAR(255),
email VARCHAR(255),
phone VARCHAR(20),
locat VARCHAR(255),
dat DATE,
tim TIME
)
"""
cursor.execute(create_table_query)
conn.commit()
cursor.close()
conn.close()
print(Fore.GREEN + "Database setup complete.\n" + Fore.RESET)
time.sleep(1)
print()


def reset_database():
print(Fore.YELLOW + "\nRe-setting the database...\n" + Fore.RESET)

db_config = {
'user': 'root',
'host': 'localhost',
'database': 'carpool1'
}

table_name = "ride"

try:
conn = mys.connect(**db_config)
cursor = conn.cursor()
except:
print(Fore.RED + "Error: Could not connect to MySQL." + Fore.RESET)
time.sleep(1)
print(Fore.YELLOW + "Try running the setup from scratch.\n" + Fore.RESET)
time.sleep(3)
return

cursor.execute(f"DROP TABLE IF EXISTS {table_name}")

create_table_query = f"""
CREATE TABLE {table_name} (
nam VARCHAR(255),
email VARCHAR(255),
phone VARCHAR(20),
locat VARCHAR(255),
dat DATE,
tim TIME
)
"""
cursor.execute(create_table_query)
conn.commit()
cursor.close()
conn.close()
print(Fore.GREEN + "Database Reset complete." + Fore.RESET)

if __name__ == "__main__":
passwd = input(Fore.YELLOW + "Enter your MySQL Password: " + Fore.RESET)
main()
Loading

0 comments on commit 2114632

Please sign in to comment.