-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
25 lines (19 loc) · 824 Bytes
/
app.py
File metadata and controls
25 lines (19 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from flask import Flask, jsonify, request
from professor_info import get_professor_info
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
@app.route('/professor', methods=['GET'])
def professor():
# Fetch the university, professor name, and optional course_id from request arguments
university = request.args.get('university')
professor_name = request.args.get('name')
course_id = request.args.get('course_id')
if not university or not professor_name:
return jsonify({"error": "Missing university or professor name"}), 400
# Call your function with all parameters
info = get_professor_info(university, professor_name, course_id)
# Return the result as JSON
return jsonify(info)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)