import streamlit
import pandas
import requests
import numpy as np
# Page Title
# streamlit.title('Blog')
# Object notation
def get_weather_data(city, api_key):
"""Fetch weather data from OpenWeatherMap API."""
url = f"https://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}&units=metric"
response = requests.get(url)
data = response.json()
return data
def display_weather(data):
"""Display weather data in a user-friendly format."""
streamlit.write(f"#### Weather in {data['name']}, {data['sys']['country']}")
streamlit.write(f"**Temperature:** {data['main']['temp']} Β°C")
streamlit.write(f"**Weather:** {data['weather'][0]['description']}")
streamlit.write(f"**Wind Speed:** {data['wind']['speed']} m/s")
streamlit.write(f"**Pressure:** {data['main']['pressure']} hPa")
streamlit.write(f"**Humidity:** {data['main']['humidity']}%")
def main():
streamlit.title("Weather Forecast") # Moved the title here
with streamlit.sidebar:
streamlit.markdown("<h3 style='text-align: center; color: grey;'>Blog Content</h3>", unsafe_allow_html=True)
streamlit.image("https://irelandtravelguides.com/wp-content/uploads/2020/06/gold-foil-tree-of-life-5262414_640.png")
streamlit.caption('_"One rarely falls in love without being as much attracted to what is interestingly wrong with someone as what is objectively healthy."β Alain de Botton_')
col1, col2, col3 = streamlit.columns(3)
col1.metric("Temperature", "70 Β°F", "1.2 Β°F")
col2.metric("Wind", "9 mph", "-8%")
col3.metric("Humidity", "86%", "4%")
city = streamlit.text_input("Enter a city name", "London")
api_key = "my_key"
if streamlit.button("Get Weather"):
weather_data = get_weather_data(city, api_key)
if weather_data.get("cod") != 404:
display_weather(weather_data)
else:
streamlit.error("City not found!")
streamlit.markdown("<h1 style='text-align: center; color: grey;'>HEALTHY CAN BE TASTY</h1>", unsafe_allow_html=True)
streamlit.image("http://www.pngall.com/wp-content/uploads/2016/07/Meditation-Transparent.png")
col4, col5, col6 = streamlit.columns(3)
with col4:
streamlit.header('Breakfast Menu')
streamlit.text('π₯£ Quinoa Breakfast Bowl')
streamlit.text(' π₯€ Green Smoothie with Kale and Banana')
streamlit.text('π³ Poached Eggs with Whole Grain Toast')
streamlit.text('π Greek Yogurt with Mixed Berries')
with col5:
streamlit.image("http://www.pngall.com/wp-content/uploads/5/Diet-PNG-Clipart.png")
with col6:
streamlit.header('Snack Menu')
streamlit.text('π Apple Slices with Almond Butter')
streamlit.text('π₯ Sliced Cucumber with Hummus')
streamlit.text('π₯ Handful of Mixed Nuts')
col1, col2, col3 = streamlit.columns(3)
with col1:
streamlit.image("https://cdn.pixabay.com/photo/2014/04/03/10/38/yoga-310940_960_720.png")
with col2:
streamlit.header('Lunch Menu')
streamlit.text('π₯ Grilled Chicken Salad with Quinoa')
streamlit.text(' π₯ Avocado and Tomato Whole Grain Wrap')
streamlit.text('π² Lentil Soup with Vegetables')
streamlit.text('π₯¦ Steamed Broccoli with Lemon')
with col3:
streamlit.image("https://cdn.pixabay.com/photo/2014/04/02/10/48/woman-304646_640.png")
col7, col8, col9 = streamlit.columns(3)
with col7:
streamlit.header('Snack Menu')
streamlit.text('π₯ Carrot Sticks with Greek Yogurt Dip')
streamlit.text('π Frozen Grapes')
streamlit.text('π΅ Green Tea')
with col8:
streamlit.image("https://cdn3.iconfinder.com/data/icons/wrestler/755/muscle_bodybuilding_bodybuilder_bicep_tricep_healthy_fitness-512.png")
with col9:
streamlit.header('Dinner Menu')
streamlit.text('π Baked Salmon with Quinoa and Asparagus')
streamlit.text(' π₯¦ Stir-Fried Tofu with Vegetables')
streamlit.text('π² Lentil Curry with Brown Rice')
streamlit.text('π Grilled Eggplant with Tomato Sauce')
col1, col2, col3 = streamlit.columns(3)
#Header of Smoothie Maker
streamlit.header('ππ₯ Build Your Own Fruit Smoothie π₯π')
#initialise the dataframe
Meanwhile, you may want to verify the path to /mount/admin/install_path
.
It might be hardcoded somewhere in your deployment configuration, so ensure the path exists or update the configuration to point to the correct location.
Hope this helps.
Best,
Charly.
Thank you,Charly! I will try to get you more information. I keep having issues deploying to Streamlit Cloud though for other projects as well, mainly module not found errors. Even though I have tried requirments.txt with or without version specification. The code works locally where I have access to the console and virtual env, but not when I deploy it.
Thank you for your support, actually I solved it by adding :
Run the app
if name == βmainβ:
main()
I forgot to run it
Glad you found the fix!
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.