Pulls repairability scores for various devices from iFixit, which are then displayed on a website in a few categories.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.9 KiB

  1. import time
  2. import csv
  3. from flask import Flask, make_response, request, render_template, redirect, url_for, send_from_directory #Import flask web server and additional components
  4. app = Flask(__name__)
  5. smartphone_file = "/home/ravi/Documents/Git/iFixit-Repairability-Dashboard/smartphone.csv"
  6. tablet_file = "/home/ravi/Documents/Git/iFixit-Repairability-Dashboard/tablet.csv"
  7. laptop_file = "/home/ravi/Documents/Git/iFixit-Repairability-Dashboard/laptop.csv"
  8. @app.route('/')
  9. def index():
  10. smartphone = []
  11. tablet = []
  12. laptop = []
  13. with open(smartphone_file, 'r', newline='') as file:
  14. bad_smartphone = []
  15. reader = csv.reader(file)
  16. for row in reader:
  17. smartphone.append(row)
  18. if row[2] == '1':
  19. message = "The " + row[0] + " " + row[1] + " is a very unrepairable device with a Repairability Score of only 1/10."
  20. bad_smartphone.append(message)
  21. print(bad_smartphone)
  22. with open(tablet_file, 'r', newline='') as file:
  23. bad_tablet = []
  24. reader = csv.reader(file)
  25. for row in reader:
  26. tablet.append(row)
  27. if row[2] == '1':
  28. message = "The " + row[0] + " " + row[1] + " is a very unrepairable device with a Repairability Score of only 1/10."
  29. bad_tablet.append(message)
  30. print(bad_tablet)
  31. with open(laptop_file, 'r', newline='') as file:
  32. bad_laptop = []
  33. reader = csv.reader(file)
  34. for row in reader:
  35. laptop.append(row)
  36. if row[2] == '1':
  37. message = "The " + row[0] + " " + row[1] + " is a very unrepairable device with a Repairability Score of only 1/10."
  38. bad_laptop.append(message)
  39. print(bad_laptop)
  40. return render_template('index.html', smartphone=bad_smartphone, tablet=bad_tablet, laptop=bad_laptop)
  41. if __name__ == '__main__':
  42. app.run(host='0.0.0.0', port=1235) #Run the webserver