Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update streamlit_app.py #193

Open
wants to merge 73 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
6f288ff
Update streamlit_app.py
Yuven23 Apr 22, 2024
1ea2b55
Update streamlit_app.py
Yuven23 Apr 22, 2024
1dcfc05
Update streamlit_app.py
Yuven23 Apr 22, 2024
5e1106d
Update streamlit_app.py
Yuven23 Apr 22, 2024
4d91390
Update streamlit_app.py
Yuven23 Apr 22, 2024
aad673a
Update requirements.txt
Yuven23 Apr 22, 2024
01fb70c
Update streamlit_app.py
Yuven23 Apr 22, 2024
e0dd606
Update streamlit_app.py
Yuven23 Apr 22, 2024
914615f
Update streamlit_app.py
Yuven23 Apr 22, 2024
698dc6a
Update streamlit_app.py
Yuven23 Apr 22, 2024
d240b86
Update streamlit_app.py
Yuven23 Apr 22, 2024
2755594
Add files via upload
Yuven23 Apr 22, 2024
60408c6
Update requirements.txt
Yuven23 Apr 22, 2024
a4f448c
Update streamlit_app.py
Yuven23 Apr 22, 2024
e581041
Update streamlit_app.py
Yuven23 Apr 22, 2024
d5bb686
Update streamlit_app.py
Yuven23 Apr 22, 2024
ec5fcd4
Update streamlit_app.py
Yuven23 Apr 22, 2024
bafc9a8
Update streamlit_app.py
Yuven23 Apr 22, 2024
43124aa
Update streamlit_app.py
Yuven23 Apr 22, 2024
52285c7
Update streamlit_app.py
Yuven23 Apr 22, 2024
2bdc934
Update streamlit_app.py
Yuven23 Apr 22, 2024
f44e9f0
Update streamlit_app.py
Yuven23 Apr 22, 2024
8c5f0dc
Update streamlit_app.py
Yuven23 Apr 22, 2024
03d1571
Update streamlit_app.py
Yuven23 Apr 22, 2024
057196c
Update streamlit_app.py
Yuven23 Apr 22, 2024
6325baf
Update streamlit_app.py
Yuven23 Apr 22, 2024
f417722
Update streamlit_app.py
Yuven23 Apr 22, 2024
8cd5e3e
Update streamlit_app.py
Yuven23 Apr 22, 2024
17c56e9
Create home.py
Yuven23 Apr 22, 2024
5bf5adb
Update streamlit_app.py
Yuven23 Apr 25, 2024
622606b
Update streamlit_app.py\
Yuven23 Apr 25, 2024
f3946cf
Update streamlit_app.py
Yuven23 Apr 25, 2024
7cd83e9
Delete home.py
Yuven23 Apr 25, 2024
07a5ed8
Update streamlit_app.py
Yuven23 Apr 25, 2024
ee5349b
Update streamlit_app.py
Yuven23 Apr 25, 2024
a21377c
Update streamlit_app.py
Yuven23 Apr 25, 2024
53195e6
Update streamlit_app.py
Yuven23 Apr 25, 2024
e51d61e
Update streamlit_app.py
Yuven23 Apr 25, 2024
3d0ba2f
Update streamlit_app.py
Yuven23 Apr 25, 2024
670a2a9
Update streamlit_app.py
Yuven23 Apr 25, 2024
3ef9be2
Rename streamlit_app.py to edu_app.py
Yuven23 Apr 25, 2024
85f4e16
Rename edu_app.py to streamlit_app.py
Yuven23 Apr 25, 2024
270ce07
Update streamlit_app.py
Yuven23 Apr 27, 2024
a187c57
Create azure-webapps-python.yml
Yuven23 Apr 27, 2024
68fdc21
Set up CI with Azure Pipelines
Yuven23 Apr 27, 2024
bdcc15c
Set up CI with Azure Pipelines
Yuven23 Apr 27, 2024
12c199c
Update streamlit_app.py
Yuven23 Apr 30, 2024
ab3076d
Update streamlit_app.py
Yuven23 Apr 30, 2024
f4780dd
Update streamlit_app.py
Yuven23 Apr 30, 2024
ea2160d
Update streamlit_app.py
Yuven23 Apr 30, 2024
c7dbf0c
Update streamlit_app.py
Yuven23 May 1, 2024
d1d8eb3
Update requirements.txt
Yuven23 May 1, 2024
03cf743
Update streamlit_app.py
Yuven23 May 1, 2024
10cf1af
Update streamlit_app.py
Yuven23 May 1, 2024
ae80ba2
Update streamlit_app.py
Yuven23 May 1, 2024
5317d52
Update streamlit_app.py
Yuven23 May 1, 2024
b5a524c
Update streamlit_app.py
Yuven23 May 1, 2024
a700e18
Update streamlit_app.py
Yuven23 May 1, 2024
b185f2f
Update streamlit_app.py
Yuven23 May 1, 2024
0746975
Update streamlit_app.py
Yuven23 May 1, 2024
8d0951b
Update streamlit_app.py
Yuven23 May 1, 2024
e8c70ff
Update streamlit_app.py
Yuven23 May 1, 2024
c40cee5
Update streamlit_app.py
Yuven23 May 1, 2024
164dd67
Update streamlit_app.py
Yuven23 May 1, 2024
18635ff
Update requirements.txt
Yuven23 May 1, 2024
7e67ef8
Update streamlit_app.py
Yuven23 May 1, 2024
b39dd6e
Update streamlit_app.py
Yuven23 May 1, 2024
3428657
Update streamlit_app.py
Yuven23 May 1, 2024
d5748fc
Update streamlit_app.py
Yuven23 May 1, 2024
29032f8
Update streamlit_app.py
Yuven23 May 1, 2024
daa10c6
Update streamlit_app.py
Yuven23 May 1, 2024
d432f62
Update streamlit_app.py
Yuven23 May 1, 2024
b9ddfd7
Update streamlit_app.py
Yuven23 May 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .github/workflows/azure-webapps-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# This workflow will build and push a Python application to an Azure Web App when a commit is pushed to your default branch.
#
# This workflow assumes you have already created the target Azure App Service web app.
# For instructions see https://docs.microsoft.com/en-us/azure/app-service/quickstart-python?tabs=bash&pivots=python-framework-flask
#
# To configure this workflow:
#
# 1. Download the Publish Profile for your Azure Web App. You can download this file from the Overview page of your Web App in the Azure Portal.
# For more information: https://docs.microsoft.com/en-us/azure/app-service/deploy-github-actions?tabs=applevel#generate-deployment-credentials
#
# 2. Create a secret in your repository named AZURE_WEBAPP_PUBLISH_PROFILE, paste the publish profile contents as the value of the secret.
# For instructions on obtaining the publish profile see: https://docs.microsoft.com/azure/app-service/deploy-github-actions#configure-the-github-secret
#
# 3. Change the value for the AZURE_WEBAPP_NAME. Optionally, change the PYTHON_VERSION environment variables below.
#
# For more information on GitHub Actions for Azure: https://github.com/Azure/Actions
# For more information on the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples

name: Build and deploy Python app to Azure Web App

env:
AZURE_WEBAPP_NAME: your-app-name # set this to the name of your Azure Web App
PYTHON_VERSION: '3.8' # set this to the Python version to use

on:
push:
branches: [ "master" ]
workflow_dispatch:

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python version
uses: actions/[email protected]
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'

- name: Create and start virtual environment
run: |
python -m venv venv
source venv/bin/activate

- name: Install dependencies
run: pip install -r requirements.txt

# Optional: Add step to run tests here (PyTest, Django test suites, etc.)

- name: Upload artifact for deployment jobs
uses: actions/upload-artifact@v3
with:
name: python-app
path: |
.
!venv/

deploy:
permissions:
contents: none
runs-on: ubuntu-latest
needs: build
environment:
name: 'Development'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: python-app
path: .

- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
26 changes: 26 additions & 0 deletions azure-pipelines-1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
trigger:
- master

pool:
vmImage: 'ubuntu-latest'

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.x' # Use the latest Python 3 version
addToPath: true

- script: |
python -m pip install --upgrade pip
pip install -r requirements.txt
displayName: 'Install dependencies'

- script: |
pytest
displayName: 'Run tests'

- script: |
streamlit_app.py # Replace app.py with the name of your Streamlit application file
displayName: 'Build Streamlit application'

# Add deployment steps here to deploy your Streamlit application to your hosting platform
36 changes: 36 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Python package
# Create and test a Python package on multiple Python versions.
# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/python

trigger:
- master

pool:
vmImage: ubuntu-latest
strategy:
matrix:
Python27:
python.version: '2.7'
Python35:
python.version: '3.5'
Python36:
python.version: '3.6'
Python37:
python.version: '3.7'

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
displayName: 'Use Python $(python.version)'

- script: |
python -m pip install --upgrade pip
pip install -r requirements.txt
displayName: 'Install dependencies'

- script: |
pip install pytest pytest-azurepipelines
pytest
displayName: 'pytest'
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
altair
pandas
streamlit
openpyxl
matplotlib
128 changes: 90 additions & 38 deletions streamlit_app.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,92 @@
import altair as alt
import numpy as np
import pandas as pd
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt

# Function to load student data from Excel sheet
def load_student_data():
# Read student data from Excel sheet
student_data = pd.read_excel("student_data.xlsx")
return student_data

# Function to filter students by course eligibility
def filter_students_by_course(course):
student_df = load_student_data()
if course == "Science":
eligible_students = student_df[student_df["Marks"] >= 80]
elif course == "Economics":
eligible_students = student_df[student_df["Marks"] >= 75]
elif course == "Humanities":
eligible_students = student_df[student_df["Marks"] >= 70]
else:
eligible_students = pd.DataFrame(columns=["Name", "Marks"]) # Return empty DataFrame if course is not recognized
return eligible_students

# Streamlit UI
st.title('Education System')

# Sidebar navigation
page = st.sidebar.radio("Navigation", ('Home', 'Add Student', 'Admission Checker', 'Course Eligibility', 'Data Visualization'))

if page == 'Home':
st.subheader('Welcome to the Education System!')
st.write("This platform allows you to manage student data and check admission eligibility.")
st.write("To get started, you can:")
st.write("- Click on 'Manage Students' to view student data.")

if st.button("Manage Students"):
student_df = load_student_data()
st.write(student_df) # Display student data

def add_student(name, marks):
student_df = load_student_data()
if name in student_df["Name"].values:
st.warning("Student already exists in the database.")
elif marks >= 75:
# Create a new DataFrame with the new student data
new_student = pd.DataFrame({"Name": [name], "Marks": [marks]})
# Append the new student DataFrame to the existing student DataFrame
student_df = pd.concat([student_df, new_student], ignore_index=True)
# Write the updated DataFrame to the Excel sheet (if needed)
# student_df.to_excel("students.xlsx", index=False)
st.success(f"{name} added successfully!")
else:
st.warning("Student not added. Marks should be 75 or greater for admission.")
return student_df # Return the updated DataFrame

if page == 'Admission Checker':
st.subheader('Admission Checker')
name = st.text_input("Enter student name to check admission:")

if st.button('Check Admission'): # Button click to check admission
student_df = load_student_data()
if name in student_df["Name"].values:
st.write("Student found.")
else:
st.write("Student not found.")

elif page == 'Course Eligibility':
st.subheader('Course Eligibility')
course = st.selectbox("Select a course:", ["Science", "Economics", "Humanities"])

st.write(f"Students eligible for {course} course:")
eligible_students = filter_students_by_course(course)
st.write(eligible_students)

elif page == 'Data Visualization':
st.subheader('Data Visualization')

# Load student data
student_df = load_student_data()

"""
# Welcome to Streamlit!

Edit `/streamlit_app.py` to customize this app to your heart's desire :heart:.
If you have any questions, checkout our [documentation](https://docs.streamlit.io) and [community
forums](https://discuss.streamlit.io).

In the meantime, below is an example of what you can do with just a few lines of code:
"""

num_points = st.slider("Number of points in spiral", 1, 10000, 1100)
num_turns = st.slider("Number of turns in spiral", 1, 300, 31)

indices = np.linspace(0, 1, num_points)
theta = 2 * np.pi * num_turns * indices
radius = indices

x = radius * np.cos(theta)
y = radius * np.sin(theta)

df = pd.DataFrame({
"x": x,
"y": y,
"idx": indices,
"rand": np.random.randn(num_points),
})

st.altair_chart(alt.Chart(df, height=700, width=700)
.mark_point(filled=True)
.encode(
x=alt.X("x", axis=None),
y=alt.Y("y", axis=None),
color=alt.Color("idx", legend=None, scale=alt.Scale()),
size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
))
# Check if the "Marks" column exists
if "Marks" not in student_df.columns:
st.error("The 'Marks' column is missing in the student data.")
else:
# Histogram of student marks distribution
st.write("Histogram of Student Marks Distribution")
fig, ax = plt.subplots()
ax.hist(student_df["Marks"], bins=10, color='skyblue', edgecolor='black')
ax.set_xlabel('Marks')
ax.set_ylabel('Frequency')
ax.set_title('Distribution of Student Marks')
st.pyplot(fig)
Binary file added student_data.xlsx
Binary file not shown.