Debugging
By Docker
- Download Docker Desktop
- Clone and go to the file path
- build the image
- docker build -t "image_name:latest" .
- run the image
- docker run -d -p 5000:5000 image_name
By local virtual machine
- start a virtual machineenvironment
| Code Block | ||||
|---|---|---|---|---|
| ||||
python3 -m venv venv |
- activate the virtual machineenvironment
| Code Block | ||||
|---|---|---|---|---|
| ||||
source venv/bin/activate |
...
| Code Block | ||||
|---|---|---|---|---|
| ||||
pip install -r requirements.txt |
- run the program
| Code Block | ||||
|---|---|---|---|---|
| ||||
flask run --debug |
By Visual Studio Code
...
Servers
The test server can be accessed from MongoDB Atlas, please follow the MongoDB Atlas section in this guide.
...
Postman is useful for sending HTTP requests to the back-end APIs.Â
- Install Postman
- CheckoutBackend Online Mobile APIs for Backend Online APIs
...
Notes (mobile)
Samples are identified by their barcode ids. If submit two surveys with the same barcode, then the latest submitted survey will replace the old one. Even if different users use the same barcode, the sample will get replaced. So when testing, if you do not scan a barcode, the sample will always be stored as no barcode, and the database will always only store the latest survey.
...
Sample Model
| Class Properties | Note |
|---|---|
_id = db.StringField(required=True) | _id is the same with barcode_id |
survey_data = db.DictField(required=False) | |
email = db.StringField(required=True) | |
image = db.ImageField() | image type can be either png or jpeg |
date_time = db.DateTimeField(required=True) | the server time when backend upload data to the DB |
milk_barcode_id = db.StringField(required=False) | |
sample_data = db.DictField(required=False) | the json file in SampleData including readable survey data |
barcode_id = db.StringField(required=True) |
User Model
| Class Properties | Note |
|---|---|
| _id = db.StringField(required=True) | _id is the same with email |
| email = db.StringField(required=True) | |
| password = db.StringField() | |
| first_name = db.StringField(max_length=50) | |
| last_name = db.StringField(max_length=50) | |
| is_real_customer = db.BooleanField(required=True) | whether the customer is a real customer |
| created_at = db.DateTimeField(required=True,default=datetime.utcnow() |
| Class Properties | Note |
|---|---|
| _id = db.StringField(required=True) | _id is the same with email |
| sign_up_survey_data = db.DictField(required=True) | store whatever survey asked and customer filled |
Survey Model
| Class Properties | Note |
|---|---|
| survey_name = db.StringField(required=True) | Name of the survey that is being retrieved |
questions = db.ListField(db.DictField(), required=False) | These are the questions that are associated with the survey. Each survey has a list of dictionaries with each dictionary representing a question |
Upload Model
To fully understand these fields, especially the sample_species_read, please contact Min-Ting Li and ask for merged data set to see data columns.
| Class Properties | Note |
|---|---|
_id = db.StringField(required = True) | id is the barcode id. example: "BS70002STOOL" |
email = db.StringField(required=True) | uploader |
| date_time = db.DateTimeField(default=datetime.datetime.now,required=True) | |
| sample_id=StringField(required=True) | sample id, example: BS7_01 |
| sample_species_read = db.DictField(required=False) | ALL data columns followed by barcode id, example: "sample_species_read": { |