A search interface for the Performing Patents Otherwise publication as part of the Politics of Patents case study (part of Copim WP6): this parses data from the archive of RTF files and provides additional data from the European Patent Office OPS API. https://patents.copim.ac.uk
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

63 行
2.1KB

  1. # @name: random.py
  2. # @creation_date: 2022-09-09
  3. # @license: The MIT License <https://opensource.org/licenses/MIT>
  4. # @author: Simon Bowie <ad7588@coventry.ac.uk>
  5. # @purpose: random route for random
  6. # @acknowledgements:
  7. from flask import Blueprint, render_template, request
  8. from . import solr
  9. from . import ops
  10. random = Blueprint('random', __name__)
  11. # route for random page
  12. @random.route('/random/')
  13. def random_record():
  14. core = 'all'
  15. results = solr.get_random_record(core)
  16. for result in results:
  17. publication_details = ops.get_publication_details(result['doc_ref'])
  18. result.update(publication_details)
  19. if ops.get_images(result['doc_ref']):
  20. image = ops.get_images(result['doc_ref'])
  21. result.update(image)
  22. return render_template('record.html', results=results)
  23. # route for comparing two random records
  24. @random.route('/random/two/')
  25. def two_random_records():
  26. core = 'all'
  27. results_list = []
  28. i = 0
  29. while i <= 1:
  30. results = solr.get_random_record(core)
  31. for result in results:
  32. publication_details = ops.get_publication_details(result['doc_ref'])
  33. result.update(publication_details)
  34. if ops.get_images(result['doc_ref']):
  35. image = ops.get_images(result['doc_ref'])
  36. result.update(image)
  37. results_list.append(result)
  38. i += 1
  39. return render_template('compare.html', results=results_list)
  40. # route for getting ten random titles
  41. @random.route('/random/titles/')
  42. def ten_random_titles():
  43. titles = solr.get_ten_random_elements('title')
  44. additional_titles = solr.get_ten_random_elements('title')
  45. return render_template('titles.html', titles=titles, additional_titles=additional_titles)
  46. # route for getting ten random abstracts
  47. @random.route('/random/abstracts/')
  48. def ten_random_abstracts():
  49. abstracts = solr.get_ten_random_elements('abstract')
  50. return render_template('abstracts.html', abstracts=abstracts)
  51. # route for getting ten random images
  52. @random.route('/random/images/')
  53. def ten_random_images():
  54. results = solr.get_ten_random_images()
  55. return render_template('images.html', results=results)