From c9452922048ee30d65d8b2c46c9892702fbbfe4d Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Thu, 2 Jul 2015 00:12:58 +0300 Subject: [PATCH] Added API Debug Routes - See The Help Page (Misc) --- SE_API/API.py | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/SE_API/API.py b/SE_API/API.py index faac0a0..670d145 100644 --- a/SE_API/API.py +++ b/SE_API/API.py @@ -205,11 +205,54 @@ def oauth(oauth_token): def login(): return github.authorize() +debug = True # Change In Production +if debug: + counter = 300 -@app.route('/debug/login') -def set_local_token_view(): - return app.send_static_file('DEBUG_Views/set_cookie.html') + @auto.doc() + @app.route('/debug/login') + def set_local_token_view(): + """ + Go To This URL To Set The SE-Token Cookie +
+ Route Parameters
+ - token: None
+
+ Payload
+ - None + Response +
+ None. + """ + return app.send_static_file('DEBUG_Views/set_cookie.html') + @auto.doc() + @app.route('/debug/createUser/') + def createUser(gitHubUserName): + """ + Go To This URL To Set The SE-Token Cookie +
+ Route Parameters
+ - gitHubUserName: A Username
+
+ Payload
+ - None + Response +
+ None. + """ + try: + query = Campus.all().filter('title =', 'JCE') + for c in query.run(limit=1): + campus = c + user = User(name=";", username=gitHubUserName, isFirstLogin=False, + avatar_url='http://placekitten.com/g/200/'+str(counter), accessToken="RandomGitHubToken", + email='username@mailservice.com', campuses_id_list=[str(campus.key().id())], + seToken=str(uuid.uuid4()), isLecturer=True) + db.put(user) + return created(gitHubUserName + 'Was Created. Token: ' + user.seToken) + except Exception as e: + return bad_request(str(e)) @app.route('/api/qa/init') def init_QA():