Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/orca-scan/orca-lookup-python
How to respond to an Orca Scan Lookup request using Python
https://github.com/orca-scan/orca-lookup-python
barcode-scanning flask python smartphone
Last synced: 3 days ago
JSON representation
How to respond to an Orca Scan Lookup request using Python
- Host: GitHub
- URL: https://github.com/orca-scan/orca-lookup-python
- Owner: orca-scan
- License: mit
- Created: 2020-10-17T19:18:09.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-28T21:44:00.000Z (over 2 years ago)
- Last Synced: 2023-03-06T17:02:24.799Z (over 1 year ago)
- Topics: barcode-scanning, flask, python, smartphone
- Language: Python
- Homepage:
- Size: 18.6 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# orca-lookup-python
This open source project is a an example of [how to scan barcodes using a smartphone](https://orcascan.com/mobile) and [present data from your system](https://orcascan.com/docs/api/lookup-url) using [Python](https://www.python.org/) and the [flask](https://github.com/pallets/flask) framework.
**How it works:**
1. A user [scans a barcode](https://orcascan.com/mobile) using their smartphone
2. Orca Scan sends a HTTP GET request to your endpoint with `?barcode=value`
3. Your system queries a database or internal API for a `barcode` match
4. Your system returns the data in JSON format with keys matching column names
5. The [Orca Scan mobile](https://orcascan.com/mobile) app presents that data to the user*If the mobile user has [update permission](https://orcascan.com/docs/getting-started/adding-users#selecting-user-permissions) and saves the data, it will saved to your Orca sheet.*
## Install
First ensure you have [Python](https://www.python.org/downloads/) installed:
**macOS or Linux**
```bash
# should return 3.7 or higher
python3 --version
```**Windows**
```bash
# should return 3.7 or higher
python --version
```Then execute the following:
```bash
# 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**
```bash
# create virtual environment and activate it
python3 -m venv orca && source ./orca/bin/activate
```
**Windows**
```bash
# create virtual environment and activate it
python -m venv orca && source ./orca/scripts/activate
```
**All**
```bash
# upgrade pip to latest version
python -m pip install --upgrade pip# install dependencies
pip install -r requirements.txt
```## Run
**macOS or Linux**
```bash
# activate virtual environment
source ./orca/bin/activate
```
**Windows**
```bash
# activate virtual environment
source ./orca/scripts/activate
```
**All**
```bash
# start the project
flask run
```Visit [http://localhost:5000?barcode=4S3BMHB68B3286050](http://localhost:5000?barcode=4S3BMHB68B3286050) to see the following:
```json
{
"VIN": "4S3BMHB68B3286050",
"Make": "SUBARU",
"Model": "Legacy",
"Manufacturer Name": "FUJI HEAVY INDUSTRIES U.S.A",
"Vehicle Type": "PASSENGER CAR",
"Year": 1992
}
```## How this example works
This [example](app.py) uses the [flask](https://github.com/pallets/flask) framework:
```python
# 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)
```## Troubleshooting
If you run into any issues not listed here, please [open a ticket](https://github.com/orca-scan/orca-lookup-python/issues).
## Examples in other langauges
* [orca-lookup-node](https://github.com/orca-scan/orca-lookup-node)
* [orca-lookup-dotnet](https://github.com/orca-scan/orca-lookup-dotnet)
* [orca-lookup-go](https://github.com/orca-scan/orca-lookup-go)
* [orca-lookup-php](https://github.com/orca-scan/orca-lookup-php)
* [orca-lookup-java](https://github.com/orca-scan/orca-lookup-java)## History
For change-log, check [releases](https://github.com/orca-scan/orca-lookup-python/releases).
## License
Licensed under [MIT License](LICENSE) © Orca Scan, the [Barcode Scanner app for iOS and Android](https://orcascan.com).