This open source project is a an example of how to scan barcodes using a smartphone and present data from your system using Python and the flask framework.
How it works:
- A user scans a barcode using their smartphone
- Orca Scan sends a HTTP GET request to your endpoint with
?barcode=value
- Your system queries a database or internal API for a
barcode
match - Your system returns the data in JSON format with keys matching column names
- The Orca Scan mobile app presents that data to the user
If the mobile user has update permission and saves the data, it will saved to your Orca sheet.
First ensure you have Python installed:
macOS or Linux
# should return 3.7 or higher
python3 --version
Windows
# should return 3.7 or higher
python --version
Then execute the following:
# download this example code
git clone https://github.com/orca-scan/orca-lookup-python.git
# go into the new directory
cd orca-lookup-python
macOS or Linux
# create virtual environment and activate it
python3 -m venv orca && source ./orca/bin/activate
Windows
# create virtual environment and activate it
python -m venv orca && source ./orca/scripts/activate
All
# upgrade pip to latest version
python -m pip install --upgrade pip
# install dependencies
pip install -r requirements.txt
macOS or Linux
# activate virtual environment
source ./orca/bin/activate
Windows
# activate virtual environment
source ./orca/scripts/activate
All
# start the project
flask run
Visit http://localhost:5000?barcode=4S3BMHB68B3286050 to see the following:
{
"VIN": "4S3BMHB68B3286050",
"Make": "SUBARU",
"Model": "Legacy",
"Manufacturer Name": "FUJI HEAVY INDUSTRIES U.S.A",
"Vehicle Type": "PASSENGER CAR",
"Year": 1992
}
This example uses the flask framework:
# GET / handler
@app.route("/")
def index():
# get the incoming barcode sent from Orca Scan (scanned by a user)
barcode = request.args.get("barcode")
# TODO: query a database or API to retrieve some data based on barcode value
data = {
"VIN": barcode,
"Make": "SUBARU",
"Model": "Legacy",
"Manufacturer Name": "FUJI HEAVY INDUSTRIES U.S.A",
"Vehicle Type": "PASSENGER CAR",
"Year": 1992
}
# return data in JSON format (property names must match Orca column names)
return jsonify(data)
If you run into any issues not listed here, please open a ticket.
For change-log, check releases.
Licensed under MIT License © Orca Scan, the Barcode Scanner app for iOS and Android.