Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,39 +1,55 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
-
import
|
|
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
email_regex = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b'
|
8 |
-
return bool(re.fullmatch(email_regex, email))
|
9 |
-
|
10 |
-
st.title("Kişisel Bilgi Formu")
|
11 |
-
|
12 |
-
# Ad ve Soyad
|
13 |
-
name = st.text_input("Adınız ve Soyadınız (küçük harf):", max_chars=50)
|
14 |
-
|
15 |
-
# Doğum Yılı
|
16 |
-
birth_year = st.number_input("Doğum Yılınız:", min_value=1900, max_value=2023, step=1)
|
17 |
|
18 |
-
#
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
st.
|
|
|
|
|
38 |
else:
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
+
import os
|
4 |
+
from datetime import datetime
|
5 |
|
6 |
+
# Form başlığı
|
7 |
+
st.title("Kişisel Bilgiler Formu")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
# Email doğrulama fonksiyonu
|
10 |
+
def is_valid_email(email):
|
11 |
+
return st.email_validator(email)
|
12 |
+
|
13 |
+
# Form alanları
|
14 |
+
with st.form(key='user_form'):
|
15 |
+
name = st.text_input("Ad ve Soyad", max_chars=50).lower()
|
16 |
+
birth_year = st.selectbox("Doğum Yılı", options=list(range(1950, datetime.now().year + 1)), index=1980-1950)
|
17 |
+
email = st.text_input("Email", help="Lütfen geçerli bir email adresi girin.")
|
18 |
+
cv = st.file_uploader("Özgeçmiş (PDF formatında, max 3MB)", type=['pdf'])
|
19 |
+
gender = st.selectbox("Cinsiyet", options=["Erkek", "Kadın", "Diğer"])
|
20 |
+
about = st.text_area("Hakkında", max_chars=500)
|
21 |
+
submit_button = st.form_submit_button(label='Gönder')
|
22 |
+
|
23 |
+
# Form doğrulama ve gönderim
|
24 |
+
if submit_button:
|
25 |
+
if not is_valid_email(email):
|
26 |
+
st.error("Geçerli bir email adresi girin.")
|
27 |
+
elif cv is None:
|
28 |
+
st.error("Lütfen özgeçmiş dosyasını yükleyin.")
|
29 |
+
elif cv.size > 3 * 1024 * 1024:
|
30 |
+
st.error("Özgeçmiş dosyası 3 MB'dan büyük olamaz.")
|
31 |
else:
|
32 |
+
# Verileri kaydetme
|
33 |
+
data = {
|
34 |
+
"Name": name,
|
35 |
+
"Birth Year": birth_year,
|
36 |
+
"Email": email,
|
37 |
+
"Gender": gender,
|
38 |
+
"About": about
|
39 |
+
}
|
40 |
+
df = pd.DataFrame([data])
|
41 |
+
|
42 |
+
# CSV dosyasına ekleme veya oluşturma
|
43 |
+
file_path = "kayitformu.csv"
|
44 |
+
if os.path.exists(file_path):
|
45 |
+
df.to_csv(file_path, mode='a', header=False, index=False)
|
46 |
+
else:
|
47 |
+
df.to_csv(file_path, mode='w', header=True, index=False)
|
48 |
+
|
49 |
+
st.success("Bilgiler başarıyla kaydedildi.")
|
50 |
+
|
51 |
+
# Kaydedilen verileri tablo olarak gösterme
|
52 |
+
if os.path.exists(file_path):
|
53 |
+
st.write("Kayıtlı Bilgiler:")
|
54 |
+
data_df = pd.read_csv(file_path)
|
55 |
+
st.dataframe(data_df)
|