A Flask-based web application that searches for volunteer work in Hong Kong, filtered by date. It aggregates data from four different websites:
- 社職 (Social Career):
https://www.socialcareer.org/ - AVS (Agency for Volunteer Service):
https://www.avs.org.hk/ - HandsOn Hong Kong:
https://handsonhongkong.org/zh/ - Time Auction:
https://timeauction.org/en
- Python 3.9+: Make sure you have Python 3.9 or a later version installed. You can check your Python version by running
python --versionorpython3 --versionin your terminal. If you don't have it, download it from python.org. - pip:
pipis the package installer for Python. It usually comes bundled with Python installations. You can check if you have it by runningpip --versionorpip3 --version. If not install bypython -m ensurepip --upgrade
-
Clone the Repository (or Download):
-
Using Git (Recommended): Open your terminal or command prompt and run:
git clone https://github.com/dylanpong1109/vol_work
-
Downloading as a ZIP: If you don't have Git, go to the GitHub repository page and click the "Code" button, then select "Download ZIP". Extract the downloaded ZIP file to a folder of your choice. Open a terminal or command prompt and navigate to that folder using the
cdcommand.
-
-
Install Dependencies:
The project's dependencies are listed in the
requirements.txtfile. Install them usingpip:pip install -r requirements.txt
Or if you have both python2 and python3 installed
pip3 install -r requirements.txt
This command installs Flask and other necessary libraries.
-
Fetch Data:
Before running the application for the first time (and periodically to update the data), you need to fetch the volunteer event data from the four websites. Run the provided script:
python fetch_data.py
Or
python3 fetch_data.py
This script will create (or update) the following JSON files in the same directory as the script:
response.json(Social Career data)response_avs.json(AVS data)response_handson.json(HandsOn Hong Kong data)response_time_auction.json(Time Auction data)
Important: This step might take a while, depending on your internet connection and the responsiveness of the target websites. The script scrapes data, so it's subject to changes in the websites' structure. If the script fails, you might need to update the scraping logic in
fetch_data.py.
-
Start the Flask Server:
Once you've fetched the data, you can start the Flask development server:
python app.py
Or
python3 app.py
You should see output similar to this:
* Serving Flask app 'app' * Debug mode: on * Running on http://127.0.0.1:5000 * Restarting with stat * Debugger is active! * Debugger PIN: xxx-xxx-xxx -
Access the Web Interface:
Open your web browser and go to
http://127.0.0.1:5000/. You should see the web interface with a date input field. -
Search for Events:
- Enter a date in the "Start Date" field (YYYY-MM-DD format).
- Click the "Search" button.
- The page will display a list of volunteer opportunities matching the selected date, aggregated from the four websites. The results are sorted by start time.
ModuleNotFoundError: No module named 'flask'(or similar errors): This means the required libraries weren't installed correctly. Double-check that you ranpip install -r requirements.txtin the correct directory (the project's root directory). You might need to usepip3instead ofpip.fetch_data.pyfails: The websites being scraped might have changed their structure. You'll need to inspect the website's HTML and update the scraping logic infetch_data.pyaccordingly. This requires some knowledge of web scraping techniques (using libraries likerequestsandBeautifulSoup).- No results are displayed:
- Make sure you've run
fetch_data.pyto populate the JSON data files. - Try a different date. There might not be any events listed for the date you selected.
- Check the terminal output for any error messages from the Flask server.
- Make sure you've run
- Web Scraping: This project relies on web scraping, which can be fragile. If the target websites change their HTML structure, the
fetch_data.pyscript will likely need to be updated. - Rate Limiting: Be mindful of how frequently you run
fetch_data.py. Scraping websites too often may lead to your IP address being blocked. - Data Accuracy: The accuracy of the displayed information depends on the data provided by the source websites.
- Development Server: The Flask development server (
app.run(debug=True)) is not suitable for production use. For deployment, you should use a production-ready WSGI server like Gunicorn or uWSGI.