Skip to content

Commit

Permalink
finishvideos
Browse files Browse the repository at this point in the history
  • Loading branch information
KartikKapur committed Feb 3, 2019
1 parent ba1bd06 commit 4a6df1e
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 13 deletions.
10 changes: 0 additions & 10 deletions Dockerfile

This file was deleted.

12 changes: 9 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand Down Expand Up @@ -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/<course_ok_id>/lecture/<lecture_url_name>/video/<int:video_index>/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
37 changes: 37 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions utils/sql_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)'
)

0 comments on commit 4a6df1e

Please sign in to comment.