Пример #1
0
 def get(self):
     user_id = get_jwt_identity()
     items = Item.find_all()
     if user_id:
         return {'items': [item.json() for item in items]}, 200
     return {
         'items': [item.name for item in items],
         'message': 'Login to view more data'
     }, 200
Пример #2
0
 def get(self):
     user_id = get_jwt_identity()
     items = [item.json() for item in Item.find_all()]
     if user_id:
         return {'items': items}, 200
     return {
         'items': [item['name'] for item in items],
         'message': 'More data available if you log in.'
     }, 200
Пример #3
0
 def get(self):
     try:
         user_id = get_jwt_identity()
         items = Item.find_all()
         items_dic = [item.json() for item in items]
         if user_id:
             return {'items': items_dic}, 200
         else:
             return {
                 'items': [item['name'] for item in items_dic],
                 'message': 'Further information is available after login.'
             }, 200
     except:
         return {'message': 'An error occurred reading data.'}, 500
Пример #4
0
from models.item import Item
from common.database import Database

# URL = "https://www.johnlewis.com/2020-apple-ipad-pro-12-9-inch-a12z-bionic-ios-wi-fi-256gb/space-grey/p4949087"
# URL = "https://www.johnlewis.com/sony-wh-xb900n-noise-cancelling-extra-bass-bluetooth-nfc-wireless-over-ear-headphones-with-mic-remote/black/p4221218"
# URL = "https://www.johnlewis.com/sony-wh-ch700n-noise-cancelling-wireless-bluetooth-nfc-over-ear-headphones-with-mic-remote/p3473406"
# TAG_NAME = "p"
# QUERY = {"class": "price price--large"}

# item = Item(URL, TAG_NAME, QUERY)
# item.save_to_mongo()

# print(item.load_price())

items = Item.find_all()
print(items)
Пример #5
0
def index():
    items = Item.find_all()
    return render_template("items/index.html", items=items)