Spaces:
No application file
No application file
| import streamlit as st | |
| def calculate_and_display(hearts, comments, followers, average_cpm): | |
| engagement_rate = ((hearts + comments) / followers) * 100 | |
| earnings = (engagement_rate / 100) * average_cpm | |
| st.markdown(f"**Engagement rate:** {engagement_rate:.2f}%") | |
| st.markdown(f"**Estimated earnings:** ${earnings:.2f}") | |
| def main(): | |
| st.title("TikTok Earnings Calculator") | |
| hearts = st.number_input("Enter the number of hearts:", min_value=0, step=1) | |
| comments = st.number_input("Enter the number of comments:", min_value=0, step=1) | |
| followers = st.number_input("Enter the number of followers:", min_value=0, step=1) | |
| average_cpm = st.number_input("Enter the average CPM (earnings per thousand views):", min_value=0.0) | |
| if st.button("Calculate"): | |
| calculate_and_display(hearts, comments, followers, average_cpm) | |
| if __name__ == "__main__": | |
| main() | |