From 4a6df1e43bcb7a79586ff12f279285287c361184 Mon Sep 17 00:00:00 2001 From: Kartik Kapur Date: Sat, 2 Feb 2019 21:31:15 -0800 Subject: [PATCH] finishvideos --- Dockerfile | 10 ---------- app.py | 12 +++++++++--- app.yaml | 37 +++++++++++++++++++++++++++++++++++++ utils/sql_client.py | 6 ++++++ 4 files changed, 52 insertions(+), 13 deletions(-) delete mode 100644 Dockerfile create mode 100644 app.yaml diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 0e03beb..0000000 --- a/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM ubuntu:latest -MAINTAINER Ajay Raj "araj@berkeley.edu" -RUN apt-get update -y -RUN apt-get install -y python3 python3-dev python3-pip nginx -COPY . /app -WORKDIR /app -RUN pip3 install -r requirements.txt -RUN python3 -m nltk.downloader stopwords -ENTRYPOINT ["python3"] -CMD ["app.py"] diff --git a/app.py b/app.py index 6a530f5..7fa1c6d 100644 --- a/app.py +++ b/app.py @@ -30,7 +30,7 @@ import consts app = Flask(__name__) -CORS(app, resources={r"/*": {"origins": os.environ.get('HERMES_UI_URL')}}) +CORS(app) app.config.from_object(Config) client = MongoClient(os.environ.get('MONGODB_URI')) @@ -968,7 +968,13 @@ def watch_video(course_ok_id, lecture_url_name, video_index, ok_id=None): for course in user_courses: if course['course_id'] == int_course_ok_id: sql_client.watch_video(user_ok_id, course_ok_id, lecture_url_name,video_index) - eturn jsonify(success=True, - message="Watched Video"), 200 + return jsonify(success=True,message="Watched Video"), 200 return jsonify(success=False, message="Can only view a lecture on Hermes for an OK course you are a part of"), 403 + +@app.route( + '/course//lecture//video//watch_video', + methods=["GET"]) +@validate_and_pass_on_ok_id +def get_lecture_attendence(course_ok_id, lecture_url_name, video_index, ok_id=None): + return diff --git a/app.yaml b/app.yaml new file mode 100644 index 0000000..4aadcaf --- /dev/null +++ b/app.yaml @@ -0,0 +1,37 @@ +runtime: python +env: flex +entrypoint: gunicorn -b :$PORT main:app + +runtime_config: + python_version: 3 + +# This sample incurs costs to run on the App Engine flexible environment. +# The settings below are to reduce costs during testing and are not appropriate +# for production use. For more information, see: +# https://cloud.google.com/appengine/docs/flexible/python/configuring-your-app-with-app-yaml +manual_scaling: + instances: 1 +resources: + cpu: 1 + memory_gb: 0.5 + disk_size_gb: 10 + +env_variables: + file: ${file(./deploy/private_env)} + MONGODB_URI: file.MONGODB_URI + DATABASE_NAME: private.MONGODB_URI + DEV_TOKEN: private.DEV_TOKEN + CLIENT_ID: private.CLIENT_ID + CLIENT_SECRET: private.CLIENT_SECRET + PIAZZA_EMAIL: private.PIAZZA_EMAIL + PIAZZA_PASSWORD: private.PIAZZA_PASSWORD + SQL_DATABASE_URL: private.SQL_DATABASE_URL + + FLASK_APP: app.py + OK_SERVER: https://okpy.org + OK_MODE: authenticate + TESTING_OK_ID: lejRej + TRANSCRIPTION_MODE: api + OAUTHLIB_INSECURE_TRANSPORT: 1 + FLASK_DEBUG: 1 + HERMES_UI_URL: http://localhost:3000 diff --git a/utils/sql_client.py b/utils/sql_client.py index d6d96f4..11fc3e4 100644 --- a/utils/sql_client.py +++ b/utils/sql_client.py @@ -56,3 +56,9 @@ def watch_video(self,user_email, course_ok_id,lecture_url_name, video_index): ) self.conn.commit() cur.close() + + def get_lecture_attendence(self, user_email, course_ok_id, lecture_url_name): + cur = self.conn.cursor() + cur.execute( + 'EXECUTE lecture_attendence(%s, %s,%s,%s)' + )