This Python Flask web application provides user registration, login, and a hangman game functionality.
- User Authentication:
- User registration with username and password validation.
- User login with session management using cookies.
- Logout functionality.
- Hangman Game:
- Retrieves words from a
words.txtfile. - Allows users to start a new game and retrieves a word based on position.
- Keeps track of user's game history, wins and played games.
- Displays hangman stages from
hangman_stages.txt.
- Retrieves words from a
- User History:
- Retrieves user's game history, wins, and word history.
- Session Management:
- Session expiration and renewal using cookies.
- Data Storage:
- User data is stored in a
users.jsonfile.
- User data is stored in a
- Python 3.6+
- Flask
- requests
- json
- datetime
- random
- secrets
- re
- colorama
-
Clone the repository:
git clone <repository_url>
-
Navigate to the project directory:
cd <project_directory>
-
Install the required packages:
pip install Flask requests colorama
-
Create a
words.txtfile with words, one word per line. -
Create a
hangman_stages.txtfile with hangman stages. -
Run the server application:
python app.py
-
Run the client application:
python client.py
- Register a new user by sending a POST request to
/registerwith username and password. - Login by sending a POST request to
/loginwith username and password. - Start a new game by sending a POST request to
/start_gamewith position. - Get user history by sending a GET request to
/get_history. - Update victory count by sending a POST request to
/update_victory. - Logout by sending a POST request to
/logout.
- Ensure that the
users.json,words.txtandhangman_stages.txtfiles are in the same directory as theapp.pyfile. - The application uses cookies for session management.
- The application includes validation for username and password inputs.
- The client script will handle the user interaction for the hangman game, including game logic and display.
אפליקציית ווב זו בפייתון Flask מספקת רישום משתמשים, התחברות ופונקציונליות של משחק האיש התלוי.
- אימות משתמשים:
- רישום משתמשים עם אימות שם משתמש וסיסמה.
- התחברות משתמשים עם ניהול סשן באמצעות עוגיות.
- פונקציונליות יציאה.
- משחק תלוי איש:
- שליפת מילים מקובץ
words.txt. - מאפשר למשתמשים להתחיל משחק חדש ושולף מילה לפי מיקום.
- עוקב אחר היסטוריית המשחקים, הניצחונות והמשחקים ששוחקו של המשתמש.
- מציג את שלבי המשחק מקובץ
hangman_stages.txt.
- שליפת מילים מקובץ
- היסטוריית משתמש:
- שולף את היסטוריית המשחקים, הניצחונות והמילים של המשתמש.
- ניהול סשן:
- פקיעת תוקף סשן וחידוש באמצעות עוגיות.
- אחסון נתונים:
- נתוני משתמש מאוחסנים בקובץ
users.json.
- נתוני משתמש מאוחסנים בקובץ
- Python 3.6+
- Flask
- requests
- json
- datetime
- random
- secrets
- re
- colorama
-
שכפל את המאגר:
git clone <repository_url>
-
נווט לספריית הפרויקט:
cd <project_directory>
-
התקן את החבילות הדרושות:
pip install Flask requests colorama
-
צור קובץ
words.txtעם מילים, מילה אחת בכל שורה. -
צור קובץ
hangman_stages.txtעם שלבי המשחק. -
הפעל את אפליקציית השרת:
python app.py
-
הפעל את אפליקציית הלקוח:
python client.py
- רשום משתמש חדש על ידי שליחת בקשת POST ל-
/registerעם שם משתמש וסיסמה. - התחבר על ידי שליחת בקשת POST ל-
/loginעם שם משתמש וסיסמה. - התחל משחק חדש על ידי שליחת בקשת POST ל-
/start_gameעם מיקום. - קבל את היסטוריית המשתמש על ידי שליחת בקשת GET ל-
/get_history. - עדכן את ספירת הניצחונות על ידי שליחת בקשת POST ל-
/update_victory. - התנתק על ידי שליחת בקשת POST ל-
/logout.
- ודא שהקבצים
users.json,words.txtו-hangman_stages.txtנמצאים באותה ספרייה כמו הקובץapp.py. - האפליקציה משתמשת בעוגיות לניהול סשן.
- האפליקציה כוללת אימות עבור קלט שם משתמש וסיסמה.
- סקריפט הלקוח יטפל באינטראקציה עם המשתמש עבור משחק תלוי איש, כולל לוגיקת משחק ותצוגה.