def login(): """ Args: { uname: pw: } Returns: { SUCCESS: error_message: (only if failure) } """ if request.method == 'GET': return app.send_static_file('partials/login.html') else: # if user is already logged in, home should just take them to user home # but if they somehow get to index.html, they are able to log in again as normal # if session.has_key('logged_in') and session['logged_in']: # user is already logged in # return jsonify({'SUCCESS':True}) try: user = db_util.get_user(request.json['uname'], request.json['pw']) session['logged_in'] = True session['id'] = user['id'] session['uname'] = user['uname'] return jsonify({'SUCCESS':True}) except sqlite3.Error as e: return jsonify(Failure('login failed.')) except db_util.ValidationException as e: session['logged_in'] = False return jsonify(Failure('Invalid username or password'))
def page_file(entry_id, file_id): full_data = get("/library/metadata/" + entry_id)["_children"][0] filename = full_data["_children"][0]["_children"][file_id]["file"] # FIXME: works only for unix-systems AND when script runs on same machine # serve file as static (strip trailing slash - it is added by the static # folder which is '/') return app.send_static_file(filename[1:])
def index(): """ First check if the user is logged in. If so, and he/she has an account, redirect him/her to the main search page. If not, redirect him/her to the intro page. """ net_id = session.get(app.config['CAS_USERNAME_SESSION_KEY'], None) user = Profile.query.filter_by(net_id=net_id).first() if net_id is not None and user is not None: data = {"net_id": net_id, "profile": user} return render_template('action.html', data=data) else: return app.send_static_file('intro.html')
def after_login(): login = session.get(app.config['CAS_USERNAME_SESSION_KEY'], None) user = User.query.filter_by(nickname=login).first() if user is None: nickname = login user = User(nickname=nickname, email=nickname+"@rice.edu") db.session.add(user) db.session.commit() remember_me = False if 'remember_me' in session: remember_me = session['remember_me'] session.pop('remember_me', None) login_user(user, remember = remember_me) return app.send_static_file('intro.html') #temporarily redirecting user to intro page, TODO: figure out logic post-login
def root(): if request.method == 'POST': Fname = request.form['first'] Lname = request.form['last'] email = request.form['email'] netId = request.form['netId'] heard = request.form['heard'] heard = request.form['dietary'] heard = request.form['hearmore'] #Authenticate and create google sheet Obj ------- json_key = json.load(open('rally-126a3be978da.json')) scope = ['https://spreadsheets.google.com/feeds'] credentials = SignedJwtAssertionCredentials(json_key['client_email'], json_key['private_key'].encode(), scope) gc = gspread.authorize(credentials) wks = gc.open("testy").sheet1 # ----------------------------------------------- # Iterate through sheet find next empty cell----- def cellIterate(): val = wks.acell('A1').value counter = 1 while val: counter += 1 cell = str('A' + str(counter)) val = wks.acell(cell).value print counter pass return counter # ----------------------------------------------- # Add person to google sheet -------------------- cellNumber = cellIterate() wks.update_acell('A' + str(cellNumber), Fname) wks.update_acell('B' + str(cellNumber), Lname) wks.update_acell('C' + str(cellNumber), email) wks.update_acell('D' + str(cellNumber), netId) wks.update_acell('E' + str(cellNumber), heard) wks.update_acell('F' + str(cellNumber), dietary) wks.update_acell('G' + str(cellNumber), hearmore) #wks.update_acell('F' + str(cellNumber), ethnicity) # ----------------------------------------------- return app.send_static_file('index.html')
def post_profile_pic(): if request.method == 'POST': file = request.files['profile_pic'] session_token = escape(session.get('token')) username = redis_connections.get(session_token) user = User.query.filter_by(username=username).first() if file and allowed_file(file.filename): filename = g.user.username + secure_filename(file.filename) file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) user.profile_pic_filename = filename db.session.commit() return jsonify({'code':'200'}) return jsonify({'code':'404'}) else: session_token = escape(session.get('token')) username = redis_connections.get(session_token) user = User.query.filter_by(username=username).first() path = os.path.join(app.config['UPLOAD_FOLDER'], user.profile_pic_filename) return app.send_static_file(path)
def profile(): return app.send_static_file('profile.html')
def index(): #api_manager.create_api(tweets,methods=['GET','POST']) return app.send_static_file('index.html')
def adminPage(): return app.send_static_file('/views/admin.html')
def old_browser(): return app.send_static_file("old_browser.html")
def send_static(path): return app.send_static_file(path)
def message(): return app.send_static_file('' + request.json['file'])
def static_proxy(path): return app.send_static_file(path)
def render_blog_img(src): # Blog static files return app.send_static_file('blog_posts/img/' + src)
def serve_story(): return app.send_static_file('story/index.html')
def catch_all(path='index.html'): if os.path.isfile('public/' + path): return app.send_static_file(path) return abort(404)
def index(): return app.send_static_file('index.html')
def index(): return app.send_static_file( os.path.join('js', 'index.html').replace('\\', '/'))
def static_img(path): return app.send_static_file(os.path.join('img', path))
def get_slides(): return app.send_static_file('slides.html')
def robots(): return app.send_static_file('files/robots.txt')
def render_humans_txt(): return app.send_static_file('public/humans.txt')
def apple_app_site_association(): return app.send_static_file('files/apple-app-site-association.json')
def static_proxy(path): # send_static_file will guess the correct MIME type return app.send_static_file(os.path.join('js', path))
def demo(): # This loads a static HTML file where we then hand over the interaction # to VueJS return app.send_static_file('partials/index.html')
def static_css(path): return app.send_static_file(os.path.join('css', path))
def root(): """ Return the app index. """ return app.send_static_file('index.html')
def index(): return app.send_static_file('html/index.html')
def catch_all(path): return app.send_static_file("index.html")
def create_session(uid): logger.info('New session opened for [' + uid + ']') return app.send_static_file("wall.html")
def send_text_file(file_name): """Send your static text file.""" file_dot_text = file_name + '.txt' return app.send_static_file(file_dot_text)
def sendrobot(): return app.send_static_file("robots.txt")
def frontend_files(url): return app.send_static_file(url)
def home(): return app.send_static_file("home.html")
def _hook(): return app.send_static_file(request.path[1:])
def download_file(filename): return app.send_static_file(filename)
def VwqXrMRgdzjBpP69cSt6LhLHYAwCwyFA(): return app.send_static_file('promotion.html')
def get_topics(): return app.send_static_file('topics.html')
def root(): return app.send_static_file('index.html')
def render_robots_txt(): return app.send_static_file('public/robots.txt')
def get_img(img): return app.send_static_file(filename="img/%s" % (img))
def render_blog_video(src): # Blog video files return app.send_static_file('blog_posts/video/' + src)
def getControllerView(): return app.send_static_file('dbgame/views/controller.html')
def getD(): return app.send_static_file('dbgame/views/directive.html')
def static_file(path): return app.send_static_file(os.path.join('static', path))
def send_text_file(file_name): file_dot_text = file_name + '.txt' return app.send_static_file(file_dot_text)
def login(): return app.send_static_file('login.html')