Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,45 +1,42 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import
|
| 3 |
|
| 4 |
-
|
| 5 |
-
CITIES = {
|
| 6 |
-
"Islamabad": "IESCO",
|
| 7 |
-
"Faisalabad": "FESCO",
|
| 8 |
-
"Hyderabad": "HESCO",
|
| 9 |
-
"Karachi": "KE",
|
| 10 |
-
"Lahore": "LESCO",
|
| 11 |
-
"Peshawar": "PESCO",
|
| 12 |
-
"Quetta": "QESCO"
|
| 13 |
-
}
|
| 14 |
-
|
| 15 |
-
# Add a select box for the user to choose the nearest city
|
| 16 |
-
city = st.selectbox("Select the Nearest City", options=list(CITIES.keys()))
|
| 17 |
-
|
| 18 |
-
# Display the selected city and corresponding company
|
| 19 |
-
st.write(f"You selected: {city}, served by: {CITIES[city]}")
|
| 20 |
-
|
| 21 |
-
# Define the URLs for each company
|
| 22 |
-
url_dict = {
|
| 23 |
"IESCO": "https://iesco.com.pk/index.php/customer-services/tariff-guide",
|
| 24 |
"FESCO": "https://fesco.com.pk/tariff",
|
| 25 |
"HESCO": "http://www.hesco.gov.pk/htmls/tariffs.htm",
|
| 26 |
"KE": "https://www.ke.com.pk/customer-services/tariff-structure/",
|
| 27 |
"LESCO": "https://www.lesco.gov.pk/ElectricityTariffs",
|
| 28 |
"PESCO": "https://pesconlinebill.pk/pesco-tariff/",
|
| 29 |
-
"QESCO": "http://qesco.com.pk/Tariffs.aspx"
|
|
|
|
| 30 |
}
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
response.raise_for_status()
|
| 40 |
-
st.write("Data fetched successfully!")
|
| 41 |
-
st.write(response.text)
|
| 42 |
-
except requests.RequestException as e:
|
| 43 |
-
st.error(f"An error occurred while fetching data: {e}")
|
| 44 |
|
| 45 |
-
|
|
|
|
|
|
| 1 |
+
# streamlit_app.py
|
| 2 |
import streamlit as st
|
| 3 |
+
import scraper
|
| 4 |
|
| 5 |
+
tariff_urls = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
"IESCO": "https://iesco.com.pk/index.php/customer-services/tariff-guide",
|
| 7 |
"FESCO": "https://fesco.com.pk/tariff",
|
| 8 |
"HESCO": "http://www.hesco.gov.pk/htmls/tariffs.htm",
|
| 9 |
"KE": "https://www.ke.com.pk/customer-services/tariff-structure/",
|
| 10 |
"LESCO": "https://www.lesco.gov.pk/ElectricityTariffs",
|
| 11 |
"PESCO": "https://pesconlinebill.pk/pesco-tariff/",
|
| 12 |
+
"QESCO": "http://qesco.com.pk/Tariffs.aspx",
|
| 13 |
+
"TESCO": "https://tesco.gov.pk/index.php/electricity-traiff"
|
| 14 |
}
|
| 15 |
|
| 16 |
+
def main():
|
| 17 |
+
st.title("PowerCalc: AI-Driven Bill & Carbon Footprint Tracker")
|
| 18 |
+
|
| 19 |
+
company = st.selectbox("Select your electricity company", list(tariff_urls.keys()))
|
| 20 |
+
appliance_name = st.text_input("Appliance Name")
|
| 21 |
+
load = st.number_input("Load of Appliance (kW)", min_value=0.0)
|
| 22 |
+
daily_usage = st.number_input("Daily Usage Time (hours)", min_value=0.0)
|
| 23 |
+
|
| 24 |
+
if st.button("Calculate"):
|
| 25 |
+
url = tariff_urls.get(company)
|
| 26 |
+
tariff_data = scraper.fetch_tariff_data(url)
|
| 27 |
+
monthly_bill = calculate_monthly_bill(tariff_data, load, daily_usage)
|
| 28 |
+
carbon_footprint = calculate_carbon_footprint(load, daily_usage)
|
| 29 |
+
|
| 30 |
+
st.write(f"Monthly Bill: {monthly_bill}")
|
| 31 |
+
st.write(f"Carbon Footprint: {carbon_footprint}")
|
| 32 |
+
|
| 33 |
+
def calculate_monthly_bill(tariff_data, load, daily_usage):
|
| 34 |
+
# Implement the bill calculation logic
|
| 35 |
+
pass
|
| 36 |
|
| 37 |
+
def calculate_carbon_footprint(load, daily_usage):
|
| 38 |
+
# Implement the carbon footprint calculation logic
|
| 39 |
+
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
+
if __name__ == "__main__":
|
| 42 |
+
main()
|