No Description
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.

server.py 966B

1234567891011121314151617181920212223242526272829303132333435
  1. from datetime import datetime
  2. import requests
  3. from flask import Flask, render_template, Response
  4. app = Flask(__name__)
  5. DAKA_MENU_XML_URL = ("http://campusdining.compass-usa.com/wpi/Pages/"
  6. "SignageXML.aspx?location=Pulse+On+Dining+Marketplace")
  7. def its_april_fools():
  8. now = datetime.now()
  9. return now.month == 4 and now.day == 1
  10. @app.route('/')
  11. def index():
  12. xsl_header = ('<?xml version="1.0"?>'
  13. '<?xml-stylesheet type="text/xsl" href="pod_menu.xsl"?>')
  14. xml_file = requests.get(DAKA_MENU_XML_URL).text
  15. return Response(xsl_header + xml_file, mimetype='text/xml')
  16. @app.route('/pod_menu.xsl')
  17. def pod_menu():
  18. xsl = render_template("pod_menu.xsl",
  19. easter_egg=its_april_fools(),
  20. date=datetime.now().strftime("%A, %B %d, %Y"))
  21. return Response(xsl, mimetype='text/xsl')
  22. if __name__ == '__main__':
  23. app.run('0.0.0.0', port=5000, debug=True)