def flash(message="", flag=False): if flag: f(flag + '/' + message) else: f(message)
import oauth2 as oauth from flask import Flask as f from flask import render_template, url_for, redirect, request, g, make_response import urllib, secrets, json app = f(__name__) @app.route('/<query>') def res(query): consumer = oauth.Consumer(secrets.KEY, secrets.SECRET) client = oauth.Client(consumer) r = client.request('http://api.rdio.com/1/', 'POST', urllib.urlencode({'method': 'search', 'query': query, 'types': 'Album', 'count': '1'})) d = json.loads(r[1]) if d['status'] == 'ok' and d['result']['number_results'] > 0: resp = make_response(d['result']['results'][0]['embedUrl']) resp.headers['Access-Control-Allow-Origin'] = '*' return resp if app.config['DEBUG']: from werkzeug import SharedDataMiddleware import os app.wsgi_app = SharedDataMiddleware(app.wsgi_app, { '/': os.path.join(os.path.dirname(__file__), 'static') }) if __name__ == '__main__': app.run(host='0.0.0.0', debug=True)
Original file is located at https://colab.research.google.com/drive/1OQz9C0DKxSnGDaZ947uaFJREHUC1IiOu """ import pandas as p import numpy as ny from matplotlib import pyplot as pl from sklearn.preprocessing import MinMaxScaler from flask import Flask as f from flask import request, redirect, url_for, render_template from flask.json import jsonify app = f(__name__) data = p.read_csv("all_stocks_5yr.csv") data = p.DataFrame.dropna(data) p.isnull(data).sum() > 0 ns = data.shape[0] cols = data.shape[1] data = data.drop(['date'], 1) data = data.drop(['Name'], 1) data = data[['high', 'open', 'low', 'close']] data_vals = data.values
def flash(message, category='message', form_errors=False): def form_errors_parse(form_errors_message): for v in form_errors_message.values(): v = [unicode(v) for v in v] yield ", ".join(v) if isinstance(message, (str, unicode)): f(message=message, category=category) if isinstance(message, dict): if form_errors: f(message=', '.join([v for v in form_errors_parse(message)]), category=category) else: f(message=', '.join(message.values()), category=category) if isinstance(message, list): f(message=', '.join(message), category=category) if isinstance(message, tuple): f(message=', '.join([v for v in message]), category=category) if is_lazy_string(message): f(message=unicode(message), category=category)
from flask import Flask as f app = f(__name__) #create instance # app.debug = True @app.route('/') #create route otherwise it will give error 404.. def hello(): return 'Hello Flask111' if __name__ == 'main': app.run( debug=True ) # if we add debug = true its mean that we dont have to refresh our page again n again...