Minor UX improvements
Browse files
app.py
CHANGED
|
@@ -21,8 +21,8 @@ if "current_user" not in st.session_state:
|
|
| 21 |
|
| 22 |
def register():
|
| 23 |
st.title("Register")
|
| 24 |
-
user_name = st.text_input("Enter user name")
|
| 25 |
-
password = st.text_input("Enter password", type="password")
|
| 26 |
if st.button("Register"):
|
| 27 |
if user_name and password:
|
| 28 |
try:
|
|
@@ -39,8 +39,8 @@ def register():
|
|
| 39 |
|
| 40 |
def login():
|
| 41 |
st.title("Login")
|
| 42 |
-
user_name = st.text_input("Enter user name")
|
| 43 |
-
password = st.text_input("Enter password", type="password")
|
| 44 |
if st.button("Login"):
|
| 45 |
if client.authenticate_user(user_name, password):
|
| 46 |
st.session_state.logged_in = True
|
|
@@ -71,7 +71,7 @@ def delete_own_user():
|
|
| 71 |
|
| 72 |
def add_post():
|
| 73 |
st.title("Add Post")
|
| 74 |
-
post_text = st.text_area("Enter post text")
|
| 75 |
if st.button("Add Post"):
|
| 76 |
try:
|
| 77 |
client.add_post(st.session_state.current_user, post_text)
|
|
@@ -89,7 +89,7 @@ def get_posts_for_user():
|
|
| 89 |
posts = client.get_posts_for_user(user_name)
|
| 90 |
st.write(f"Posts for user '{user_name}':")
|
| 91 |
for post in posts:
|
| 92 |
-
st.
|
| 93 |
except KeyError as e:
|
| 94 |
st.error(f"Error: {e}")
|
| 95 |
|
|
@@ -102,7 +102,7 @@ def get_posts_for_topic():
|
|
| 102 |
posts = client.get_posts_for_topic(topic)
|
| 103 |
st.write(f"Posts for topic '{topic}':")
|
| 104 |
for post in posts:
|
| 105 |
-
st.
|
| 106 |
|
| 107 |
|
| 108 |
def get_trending_topics():
|
|
@@ -136,6 +136,7 @@ def get_all_posts():
|
|
| 136 |
<div class="post-container">
|
| 137 |
<div class="post-header">{user_name}</div>
|
| 138 |
<div class="post-content">{post.content}</div>
|
|
|
|
| 139 |
</div>
|
| 140 |
""",
|
| 141 |
unsafe_allow_html=True,
|
|
|
|
| 21 |
|
| 22 |
def register():
|
| 23 |
st.title("Register")
|
| 24 |
+
user_name = st.text_input("Enter user name", placeholder="Username")
|
| 25 |
+
password = st.text_input("Enter password", type="password", placeholder="Password")
|
| 26 |
if st.button("Register"):
|
| 27 |
if user_name and password:
|
| 28 |
try:
|
|
|
|
| 39 |
|
| 40 |
def login():
|
| 41 |
st.title("Login")
|
| 42 |
+
user_name = st.text_input("Enter user name", placeholder="Username")
|
| 43 |
+
password = st.text_input("Enter password", type="password", placeholder="Password")
|
| 44 |
if st.button("Login"):
|
| 45 |
if client.authenticate_user(user_name, password):
|
| 46 |
st.session_state.logged_in = True
|
|
|
|
| 71 |
|
| 72 |
def add_post():
|
| 73 |
st.title("Add Post")
|
| 74 |
+
post_text = st.text_area("Enter post text", placeholder="What's happening?")
|
| 75 |
if st.button("Add Post"):
|
| 76 |
try:
|
| 77 |
client.add_post(st.session_state.current_user, post_text)
|
|
|
|
| 89 |
posts = client.get_posts_for_user(user_name)
|
| 90 |
st.write(f"Posts for user '{user_name}':")
|
| 91 |
for post in posts:
|
| 92 |
+
st.markdown(f"**{user_name}**: {post.content} - *{post.timestamp}*")
|
| 93 |
except KeyError as e:
|
| 94 |
st.error(f"Error: {e}")
|
| 95 |
|
|
|
|
| 102 |
posts = client.get_posts_for_topic(topic)
|
| 103 |
st.write(f"Posts for topic '{topic}':")
|
| 104 |
for post in posts:
|
| 105 |
+
st.markdown(f"**{post.user_name}**: {post.content} - *{post.timestamp}*")
|
| 106 |
|
| 107 |
|
| 108 |
def get_trending_topics():
|
|
|
|
| 136 |
<div class="post-container">
|
| 137 |
<div class="post-header">{user_name}</div>
|
| 138 |
<div class="post-content">{post.content}</div>
|
| 139 |
+
<div class="post-timestamp">{post.timestamp}</div>
|
| 140 |
</div>
|
| 141 |
""",
|
| 142 |
unsafe_allow_html=True,
|