This is a simple Flask application that generates QR codes for Bakong payments. It provides an API endpoint to fetch QR codes based on specific transaction data.
- Generates QR codes using the Bakong KHQR library.
- Provides a RESTful API to access generated QR codes.
- Supports Cross-Origin Resource Sharing (CORS) for frontend applications.
- Python 3.x
- Flask
- Flask-CORS
- qrcode
- dotenv for environment variable management
- bakong-khqr library for QR code generation
- Python 3.6 or higher
- pip
git clone https://github.com/gavined1/qr_bakong.git
cd qr_bakong
- Create a virtual environment:
This step will create an isolated environment for your project dependencies.
python -m venv .venv
- Activate the virtual environment:
On Windows:
.venv\Scripts\activate
On macOS/Linux:
source .venv/bin/activate
Once activated, your command prompt will change to indicate that you're now working inside the virtual environment.
After activating your virtual environment, install the required packages:
pip install -r requirements.txt
Create a .env file in the root directory of the project and add the following variable:
BAKONG_DEV_TOKEN=your_bakong_developer_token_here
You can start your Flask application by using one of the following methods:
- Using the Flask CLI:
If you have set the FLASK_APP environment variable to point to your application file (for example, app.py), you can run:
flask run
If you haven't set it, you can do so by running:
On Windows:
set FLASK_APP=app.py
On macOS/Linux:
export FLASK_APP=app.py
- Running the Script Directly:
If you prefer or if your script has a main block, you can run it directly with Python:
python app.py
Open another terminal window in a different directory (where your index.html is located). Run the HTTP server on a different port (like 8000):
python -m http.server 8000
Open your web browser and navigate to:
http://localhost:8000/index.html