example_server.py 641 B

123456789101112131415161718192021222324
  1. from flask import Flask
  2. from flask import render_template, request, send_from_directory, jsonify
  3. from pprint import pprint
  4. app = Flask(__name__, template_folder='./')
  5. app.config['DEBUG'] = True
  6. @app.route('/<path:path>')
  7. def send_static(path):
  8. return send_from_directory('./', path)
  9. @app.route('/submit_grade', methods=["GET", "POST"])
  10. @app.route('/submit_grade/', methods=["GET", "POST"])
  11. def submit_grade():
  12. pprint(request.values)
  13. return jsonify({"success": True, "message": "It uploaded!"})
  14. @app.route('/')
  15. def index():
  16. return render_template('blockpy_new.html')
  17. if __name__ == "__main__":
  18. app.run(port=8000)