Exemplo n.º 1
0
def create_app(config_name):
    app = Flask(__name__)

    app.config.from_object(config[config_name])
    app.config.from_envvar('remap-config')

    config[config_name].init_app(app)

    db.init_app(app)
    GoogleMaps(app)

    login_manager.init_app(app)

    from app.main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint, url_prefix='/auth')

    from .project import project as project_blueprint
    app.register_blueprint(project_blueprint, url_prefix='/project')

    from .profile import profile as profile_blueprint
    app.register_blueprint(profile_blueprint, url_prefix='/profile')

    return app
Exemplo n.º 2
0
def create_app():
    app = Flask(__name__)
    app.config['SECRET_KEY'] = 'my_app_secret'

    # MYSQL CONFIGURATIONS
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///scrap_database.sqlite'
    scrap_database.init_app(app)

    # maps config
    app.config['GOOGLEMAPS_KEY'] = "8JZ7i18MjFuM35dJHq70n3Hx4"

    GoogleMaps(app, key="8JZ7i18MjFuM35dJHq70n3Hx4")

    login_manager = LoginManager()
    login_manager.login_view = 'auth.login'
    login_manager.init_app(app)

    from src.models import User

    @login_manager.user_loader
    def load_user(user_id):
        return User.query.get(int(user_id))

    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint)

    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    return app
Exemplo n.º 3
0
def create_app():
    app = Flask(
        __name__,
        static_url_path="/static",
        instance_relative_config=True
    )

    GoogleMaps(app, key="AIzaSyADCxm6oxGCYP94Gq7igqtczUDycRvTbJU")
    
    # load configuration
    configMode = os.environ.get("app_configuration", "Config")
    app.config.from_object("config." + str(configMode))

    with app.app_context():
        # database setup
        from rounded.models import db
        db.init_app(app)
        migrate = flask_migrate.Migrate(app, db)

        firebase.connect()
        redis.init()

        # default app related views
        from rounded.views.controller import views

        # import other blueprints
        from rounded.mod_voting.controller import mod_voting

        # register controller blueprinters
        app.register_blueprint(views)
        app.register_blueprint(mod_voting, url_prefix="/voting")

    return app
Exemplo n.º 4
0
def add_crag():
    # Google Map instance for plotting exact crag coordinates.
    mymap = GoogleMaps.Map(
        identifier="view-side",
        lat=31.9171,
        lng=-106.0391,
    )
    if request.method == 'POST':
        # Pull form data into a dict
        area_dict = {
            'name': request.form['name'],
            'city': request.form['city'],
            'state': request.form['state'],
            'longitude': request.form['longitude'],
            'latitude': request.form['latitude']
        }

        # use dict to create a ClimbingArea instance.
        add_area = ClimbingArea(area_dict)
        try:
            # Write instance to crags db
            db.session.add(add_area)
            db.session.commit()
            return redirect('/')
        except:
            return "There was an issue adding the area"
    else:
        # Display Form for adding a new crag
        return render_template('addarea.html', mymap=mymap)
Exemplo n.º 5
0
def create_app():
    app = Flask(__name__)

    app.config['SECRET_KEY'] = 'secret-key-goes-here'
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'
    app.config['GOOGLEMAPS_KEY'] = ""
    db.init_app(app)
    login_manager = LoginManager()
    login_manager.login_view = 'auth.login'
    login_manager.init_app(app)
    GoogleMaps(app)
    from .models import User

    @login_manager.user_loader
    def load_user(user_id):
        # since the user_id is just the primary key of our user table, use it in the query for the user
        return User.query.get(int(user_id))

    # blueprint for auth routes in our app
    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint)

    # blueprint for non-auth parts of app
    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    return app
Exemplo n.º 6
0
def create_app(config_object=settings):
    # create and configure the app
    app = Flask(__name__, instance_relative_config=True)
    app.config.from_object(config_object)

    gm = GoogleMaps(app, key="REDACTED")

    register_extensions(app)
    register_blueprints(app)
    register_errorhandlers(app)
    return app
Exemplo n.º 7
0
def create_app(test_config=None):
    # Creates Instance & Tells App where files are relative
    app = Flask(__name__, instance_relative_config=True)

    """ Sets configuration for DB with SQLITE3 """
    app.config.from_mapping(
        SECRET_KEY='dev',
        DATABASE=os.path.join(app.instance_path, 'imprint.sqlite')
    )

    app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER # Sets configuration for images

    # config for google maps
    app.config['GOOGLEMAPS_KEY'] = config.mapsKey
    GoogleMaps(app)

    # a simple page that says hello
    @app.route('/')
    def hello():
        return  render_template('index.html')

    @app.route('/website')
    def website_index():
        return render_template('index.html')

    """ Adding Database to 'app' """
    from . import db
    db.init_app(app)

    """ Adding Authroization to 'app'"""
    from . import auth
    app.register_blueprint(auth.bp)

    """ Adding admin dashboard panel """
    from . import dashboard
    app.register_blueprint(dashboard.bp)

    """ Adding blog """
    from . import blog
    app.register_blueprint(blog.bp)

    """ Adding Pages"""
    from . import product_page
    app.register_blueprint(product_page.bp)

    """ Add Landing Page"""
    from . import landing_page
    app.register_blueprint(landing_page.bp)

    """ ADdress """
    from . import address
    app.register_blueprint(address.bp)

    return app
Exemplo n.º 8
0
def create_app(spark_context):
    global recommendation_engine
    recommendation_engine = YelpRecommenderEngine(
        {'spark_context': spark_context})
    app = Flask(__name__)
    app.register_blueprint(main)
    app.static_folder = 'static'
    Bootstrap(app)
    Bower(app)
    GoogleMaps(app, key='AIzaSyAT3qnHmIi6ujVBhyoFGtgwKIPQMPaTWA4')
    return app
def create_app(config_object=settings):
    # create and configure the app

    app = Flask(__name__, instance_relative_config=True)
    app.config.from_object(config_object)

    gm = GoogleMaps(app, key="AIzaSyCt_HeBKWlD7QZg2jH4qSaqEMPYYflkxYU")

    register_extensions(app)
    register_blueprints(app)
    register_errorhandlers(app)
    return app
Exemplo n.º 10
0
def create_app(config_class=Config):
    app = Flask(__name__)
    app.config.from_object(Config)

    db.init_app(app)
    bcrypt.init_app(app)
    login_manager.init_app(app)
    mail.init_app(app)
    GoogleMaps.init_app(app)

    from tabadol.users.routes import users
    from tabadol.posts.routes import posts
    from tabadol.main.routes import main
    from tabadol.errors.handlers import errors

    app.register_blueprint(users)
    app.register_blueprint(posts)
    app.register_blueprint(main)
    app.register_blueprint(errors)

    return app
Exemplo n.º 11
0
def create_app(config_name=DEVELOPMENT_CONFIG_NAME):
    app = Flask(__name__)
    app.config.from_object(config[config_name])

    register_extensions(app)
    register_blueprints(app)
    init_celery(app, celery)

    GoogleMaps(app)

    set_indico_key(config[config_name])

    return app
Exemplo n.º 12
0
def create_app(config_name):
    if os.getenv('FLASK_CONFIG') == "production":
        app = Flask(__name__)
        app.config.update(
            SECRET_KEY=os.getenv('SECRET_KEY'),
            SQLALCHEMY_DATABASE_URI=os.getenv('SQLALCHEMY_DATABASE_URI')
        )
    else:
        app = Flask(__name__, instance_relative_config=True)
        app.config.from_object(app_config[config_name])
        app.config.from_pyfile('config.py')
        
    #set key sebagai config
    app.config['GOOGLEMAPS_KEY'] = "AIzaSyAyoxpbvRDXrAdzZxkDqLxG20U1p1EjAKU"

    #inisialisasi extensi
    GoogleMaps(app)
    Bootstrap(app)
    db.init_app(app)
    login_manager.init_app(app)
    login_manager.login_message = "Kamu harus login untuk melihat halaman ini."
    login_manager.login_view = "auth.login"
    migrate = Migrate(app, db)

    from app import models

    from .admin import admin as admin_blueprint
    app.register_blueprint(admin_blueprint, url_prefix='/admin')

    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint)

    from .home import home as home_blueprint
    app.register_blueprint(home_blueprint)

    from .user import user as user_blueprint
    app.register_blueprint(user_blueprint)

    @app.errorhandler(403)
    def forbidden(error):
        return render_template('errors/403.html', title='Forbidden'), 403

    @app.errorhandler(404)
    def page_not_found(error):
        return render_template('errors/404.html', title='Page Not Found'), 404

    @app.errorhandler(500)
    def internal_server_error(error):
        return render_template('errors/500.html', title='Server Error'), 500

    return app
Exemplo n.º 13
0
def create_app(bind='development',
               debug=False,
               default_config=None,
               mysql_path=None):

    app = Flask(__name__)

    if default_config is None:
        app.config.from_pyfile('../../etc/frontend_default.cfg')
    else:
        app.config.from_object(default_config)

    try:
        env_config = 'FRONTEND_FOR_TWEETS_SETTINGS'
        if os.getenv(env_config) is not None:
            app.config.from_envvar(env_config)
        else:
            app.logger.info(
                "Environment variable {} was not set.".format(env_config))
    except Exception as e:
        app.logger.error("Error: {}".format(e.message))

    # set logger format and logging level
    logging.basicConfig(format=app.config['LOG_FORMAT'],
                        level=app.config['LOG_LEVEL'])
    app.debug_log_format = app.config['LOG_FORMAT']

    # set up database
    if mysql_path is None:
        app.engine = create_engine(app.config['SQLALCHEMY_BINDS'][bind],
                                   convert_unicode=True,
                                   pool_recycle=3600,
                                   pool_size=10)
    else:
        app.engine = create_engine(mysql_path,
                                   convert_unicode=True,
                                   pool_recycle=3600,
                                   pool_size=10)

    app.db_session = scoped_session(
        sessionmaker(autocommit=False, autoflush=False, bind=app.engine))

    # set debug
    app.debug = debug

    app.register_blueprint(google_map)
    google_map.logger = app.logger

    GoogleMaps(app)
    return app
Exemplo n.º 14
0
def create_app():
    app = Flask(__name__)
    app.config['SECRET_KEY'] = 'mysite'
    app.config['SQLALCHEMY_DATABASE_URI'] = \
        'sqlite:///' + os.path.join(basedir, 'data.sqlite')
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    from flaskr.views import bp
    app.register_blueprint(bp)
    db.init_app(app)
    migrate.init_app(app, db)
    login_manager.init_app(app)
    from flask_googlemaps import GoogleMaps, Map
    api_key = 'AIzaSyCXF164yON68t8Kddfel51JBDliZPGZqIk'
    GoogleMaps(app, key=api_key)
    return app
Exemplo n.º 15
0
 def __init__(self):
     self.cv = Condition()
     self.app = Flask(__name__)
     self.app.config['GOOGLEMAPS_KEY'] = "AIzaSyDcA0xJAaREE2vCdgjDnE-j9HQDChCvmWg"
     GoogleMaps(self.app)
     self.geolocator = Nominatim(user_agent="example app")
     self.login_manager = LoginManager(self.app)
     engine = create_engine('postgres://*****:*****@ec2-54-196-1-212.compute-1.amazonaws.com:5432/d77flf5a3j6r0c', echo=False)
     #engine = create_engine('sqlite:///cas.db')
     Base.metadata.create_all(engine)
     Session = sessionmaker(bind=engine)
     self.session = Session()
     self.app.config['DEBUG'] = True
     self.app.config['SECRET_KEY'] = '5791628bb0b13ce0c676dfde280ba245'
     self.position = {'latitude': 0, 'longitude': 0}
     self.locations = []
Exemplo n.º 16
0
def create_app():
    app = Flask(__name__)
    app.config['GOOGLEMAPS_KEY'] = config.GOOGLEMAPS_KEY
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.config['SQLALCHEMY_DATABASE_URI'] = config.SQLALCHEMY_DATABASE_URI
    db.init_app(app)

    GoogleMaps(app)

    @app.route("/")
    def index():

        engine = create_engine(config.SQLALCHEMY_DATABASE_URI_LOCAL)
        connection = engine.connect()

        mymap = Map(
            identifier="view-side",
            lat=27.4419,
            lng=-112.1419,
        )

        markers = []
        rows = connection.execute(
            "SELECT latitude,longitude,callsign,datetime \
            FROM (SELECT   t.*, MAX(datetime) OVER (partition BY callsign) maxdatetime \
            FROM PUBLIC.trace AS t) AS tt \
            WHERE tt.datetime=tt.maxdatetime \
            ORDER BY callsign").fetchall()

        for row in rows:
            markers.append({
                'icon': 'http://maps.google.com/mapfiles/ms/icons/plane.png',
                'lat': row[0],
                'lng': row[1],
                'infobox': f"<b>{row[2]}</b>"
            })

        sndmap = Map(identifier="sndmap",
                     lat=55.9000,
                     lng=37.7800,
                     markers=markers,
                     zoom=3,
                     style="height:720px;width:1100px;margin:0;")

        return render_template('index.html', mymap=mymap, sndmap=sndmap)

    return app
Exemplo n.º 17
0
    def __init__(self):
        # Flask initialisation
        self.app = Flask(__name__)
        # Google maps API key (necessary for requesting map data)
        self.app.config[
            'GOOGLEMAPS_KEY'] = "AIzaSyBkFBjMxRZsKjoqDC9DrH0VWn2PNLxLdJo"

        # Initialize the extension
        GoogleMaps(self.app)

        # add links on your flask app here in the format:
        # self.app.add_url_rule('URL NAME', view_func=CLASS NAME OF EXTENSION.as_view('REPRESENTATIVE CLASS NAME'))
        self.app.add_url_rule('/', view_func=Intro.as_view(''))
        self.app.add_url_rule('/index', view_func=Home.as_view('index'))
        self.app.add_url_rule('/bot', view_func=Recommend.as_view('bot'))
        self.app.add_url_rule('/recommend',
                              view_func=Recommend.as_view('recommend'))
        self.app.add_url_rule('/topic', view_func=Topic.as_view('topic'))
        # reads all destinations from all_destinations.csv for wikipedia api
        # tmp_df = pd.read_csv(str(os.getcwd() + '//all_destinations.csv'), sep=';', encoding="latin-1")
        # tmp_df.replace('\s+', '_',regex=True,inplace=True)
        # self.dest_as_list = [tmp_df.loc[x, :].values.tolist() for x in range(len(tmp_df)) if not pd.isnull(tmp_df.loc[x][1])]
        # tmp_df = None

        # loop over previous defined list and extract all destinations information via REST API if not exists already
        # AIM: centralize all APIs in scirpt destinations_api.py to extract information and safe as .txt
        # print('setting up information about total {0} destinations'.format(str(len(self.dest_as_list))))
        # self.destinations_wikipedia = {}
        # for each_destination in self.dest_as_list:
        #    self.destinations_wikipedia[each_destination[0]] = Destination(each_destination[0], each_destination[1])

        # Write collected data into database (neo4j)
        print('setting up database...')
        self.db_connection = Database()

        # Calculate similarity between destination texts
        print('calculation similarity...')
        self.language_module = LanguageProcessing(self.db_connection)
        if create_topics:
            self.language_module.save_topics(3, 10)

        # Setting up flask app on specified port
        print('setting up user interface...')
        self.app.run(host='0.0.0.0', port=80, debug=False)
Exemplo n.º 18
0
 def post(self):
     if self.db.is_first_run():
         username = request.form['settings-name']
         birthdate = request.form['settings-birth']
         gender = request.form['settings-gender']
         weight = int(request.form['settings-weight'])
         gmap_apikey = request.form['settings-mapskey']
         password = pbkdf2_sha256.encrypt(request.form['settings-pass'],
                                          rounds=200000,
                                          salt_size=16)
         self.db.update_settings(username,
                                 birthdate,
                                 gender,
                                 weight,
                                 gmap_apikey,
                                 password=password)
         GoogleMaps(current_app, key=self.db.get_gmaps_api_key())
         return url_for('login_view')
     else:
         return url_for('index_view')
Exemplo n.º 19
0
def creat_app(config_name):
    app = Flask(__name__, static_folder='adminDashboard/base/static')
    app.config.from_object(config_by_name[config_name])
    app.config['GOOGLEMAPS_KEY'] = "AIzaSyBp1G6tb0v3JzSfcPtmKGwLI018Q-DL41E"
    GoogleMaps(app)
    db.init_app(app)
    cors.init_app(app)
    login_manager.init_app(app)
    bcrypt.init_app(app)
    rq.init_app(app)
    QRcode(app)
    # register blueprints

    # test
    app.register_blueprint(root)

    # Admin Dashboard blueprints
    app.register_blueprint(api_bl)
    app.register_blueprint(base_admin)
    app.register_blueprint(home_admin)
    app.register_blueprint(factory_admin)
    app.register_blueprint(company_admin)
    app.register_blueprint(driver_admin)
    app.register_blueprint(orders_admin)

    # Company Dashboard blueprint
    app.register_blueprint(home_company)
    app.register_blueprint(cars_company)
    app.register_blueprint(drivers_company)
    app.register_blueprint(orders_company)

    # Factory Dashboard blueprint
    app.register_blueprint(factory_blueprint)
    app.register_blueprint(orders_factory)
    app.register_blueprint(new_order_factory)

    r = Redis(os.getenv('REDIS_URL', 'redis://localhost:6379'))

    return app, r
Exemplo n.º 20
0
def create_app():
    app = Flask(__name__)
    app.config[
        'SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:enazumaeleven@localhost/safedrive'
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
    app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY') or '3cjdaj#dsalp'
    app.config['INCIDENTS_PER_PAGE'] = 10
    app.config['GOOGLEMAPS_KEY'] = "AIzaSyDxrZwnqA7Tm9uLeguM8XK78GqB-ZHIbJE"
    GoogleMaps(app)
    bootstrap.init_app(app)
    database.init_app(app)
    login_manager.init_app(app)
    moment = Moment(app)

    from authentication import authentication as authentication_blueprint
    app.register_blueprint(authentication_blueprint)

    from safedrive import safedrive as safedrive_blueprint
    app.register_blueprint(safedrive_blueprint)

    return app
Exemplo n.º 21
0
def create_app():
    # init Flask
    app = Flask(__name__)

    # install bootstrap extension
    Bootstrap(app)

    # Use application factory:
    # import blueprint and register it to app
    # defined the prefix url to separate each service

    # Home Page
    app.register_blueprint(home_blueprint)
    # Map Page
    app.register_blueprint(map_blueprint)

    app.config['TEMPLATES_AUTO_RELOAD'] = True

    # Initialize the extension and register
    GoogleMaps(app, key="AIzaSyCnJzJWFZEawx6AwTJiALRWa6MB0aLsvN8")

    return app
Exemplo n.º 22
0
def create_app():
    """
    Create the app

    Can receive a string that specifies the configuration to use

    """

    app = Flask(__name__)

    app.config['WTF_CSRF_SECRET_KEY'] = WTF_CSRF_SECRET_KEY
    app.config['SECRET_KEY'] = SECRET_KEY

    for bp in blueprints:
        app.register_blueprint(bp)
        bp.app = app

    login_manager.init_app(app)

    GoogleMaps(app)

    filters.init_app(app)

    return app
def create_app(config_class=Config):
    app = Flask(__name__)
    app.config.from_object(Config)
    GoogleMaps(app)

    #db.init_app(app)
    bcrypt.init_app(app)
    #login_manager.init_app(app)
    mail.init_app(app)

    from flaskblog.users.routes import users
    from flaskblog.posts.routes import posts
    from flaskblog.main.routes import main
    from flaskblog.errors.handlers import errors
    from flaskblog.maps.routes import maps
    from flaskblog.resource.routes import resource
    app.register_blueprint(users)
    app.register_blueprint(posts)
    app.register_blueprint(main)
    app.register_blueprint(errors)
    app.register_blueprint(maps)
    app.register_blueprint(resource)

    return app
Exemplo n.º 24
0
 def start(self):
     log.info(
         'starting runnerdash, base_path: %s, db: %s, port: %d, debug: %s', cfg.base_path, cfg.db_file, self.port,
         self.debug
     )
     self.app.add_url_rule('/', view_func=IndexView.as_view('index_view'))
     self.app.add_url_rule('/api', view_func=APIView.as_view('api_view'))
     self.app.add_url_rule('/wizard', view_func=WizardView.as_view('wizard_view'))
     self.app.add_url_rule('/login', view_func=LoginView.as_view('login_view'))
     self.app.add_url_rule('/logout', view_func=LogoutView.as_view('logout_view'))
     self.app.add_url_rule('/dashboard', view_func=DashboardView.as_view('dashboard_view'))
     self.app.add_url_rule('/settings', view_func=SettingsView.as_view('settings_view'))
     self.app.add_url_rule('/statistics', view_func=StatisticsView.as_view('statistics_view'))
     self.notify.start()
     db = RunnerDB(cfg.db_file)
     gmap_apikey = db.get_gmaps_api_key()
     if gmap_apikey:
         GoogleMaps(self.app, key=gmap_apikey)
     login_manager.login_view = "login_view"
     login_manager.setup_app(self.app)
     if self.devel:
         self.app.config['TEMPLATES_AUTO_RELOAD'] = True
     self.app.secret_key = db._generate_random_api_key()
     self.app.run(host=self.host, port=self.port, debug=self.debug, use_reloader=self.devel)
Exemplo n.º 25
0
from config import Config
from logging.handlers import RotatingFileHandler
from flask_login import LoginManager
from flask_bootstrap import Bootstrap
import os
import logging
from flask_googlemaps import GoogleMaps

app = Flask(__name__)
app.config.from_object(Config)
db = MongoEngine(app)
login = LoginManager(app)
login.login_view = 'login'
bootstrap = Bootstrap(app)
app.config['GOOGLEMAPS_KEY'] = os.environ.get('GOOGLEMAPS_KEY')
GoogleMaps(app)

if not app.debug:
    if not os.path.exists('logs'):
        os.mkdir('logs')
    file_handler = RotatingFileHandler('logs/porchfest_BAG.log',
                                       maxBytes=10240,
                                       backupCount=10)
    file_handler.setFormatter(
        logging.Formatter(
            '%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'
        ))
    file_handler.setLevel(logging.INFO)
    app.logger.addHandler(file_handler)

    app.logger.setLevel(logging.INFO)
Exemplo n.º 26
0
def create_app():
    app = Flask(__name__, template_folder='templates')
    GoogleMaps(app, key=GOOGLEMAPS_KEY)
    return app
Exemplo n.º 27
0
    dist_station = 0
    weather_data = "N/A"
    asked_stations = "N/A"
    return closest_location, dist_station, weather_data, asked_stations


########### 2 NOTE SITE LIST ######################

# import list of locations. Contains sites and coordinates.
sites_coord = pd.read_excel("sites/my_sites.xlsx")

########### 3 NOTE FLASK APP ######################
# initialize Flask application
app = Flask(__name__)

GoogleMaps(app)  # used to show available stations on map


@app.route('/')
def home():

    return (render_template('home.html'))


@app.route("/get_weather_data", methods=['GET', 'POST'])
def get_weather_data():
    # get all available weather parameters
    smhi_weather_parameters = smhi_parameters()

    if request.method == 'POST':
        site_id = request.form["site_id"]
Exemplo n.º 28
0
client = pymongo.MongoClient(
    "mongodb+srv://gabrielelkadki:[email protected]/test?retryWrites=true&w=majority"
)

db = client.test
collection = db.coordinates

app = Flask(__name__, template_folder="templates")
app.secret_key = b'_5#y2L"F4Q8z\n\xec]/'
app.config['SESSION_TYPE'] = 'filesystem'

Session(app)

key = "AIzaSyDzLfe1r1aV48C15pGg_-PI0m0upPwFi3U"
GoogleMaps(app, key=key)


def geocode(address=None,
            components=None,
            bounds=None,
            region=None,
            language=None):
    """
    Geocoding is the process of converting addresses
    (like ``"1600 Amphitheatre Parkway, Mountain View, CA"``) into geographic
    coordinates (like latitude 37.423021 and longitude -122.083739), which you
    can use to place markers or position the map.
    :param address: The address to geocode.
    :type address: string
    :param components: A component filter for which you wish to obtain a
import sys
import requests
import json
import category_predictor

# App config.
# DEBUG = True
application = Flask(__name__, template_folder="templates")
application.config.from_object(__name__)
application.config['SECRET_KEY'] = '7d441f27d441f27567d441f2b6176a'
# you can set key as config
application.config[
    'GOOGLEMAPS_KEY'] = "AIzaSyAXozhGr5tKlXS4l8FRri4CX36aTviOzXk"

# you can also pass key here
GoogleMaps(application, key="AIzaSyAXozhGr5tKlXS4l8FRri4CX36aTviOzXk")


class ReusableForm(Form):
    food = TextField('Food:', validators=[validators.required()])


class ReviewCategoryClassifier(object):
    """Predict categories for text using a simple naive-bayes classifier."""
    @classmethod
    def load_data(cls, input_file):
        """Read the output of the CategoryPredictor mrjob, returning
		total category counts (count of # of reviews for each
		category), and counts of words for each category.
		"""
Exemplo n.º 30
0
from wtforms.validators import Email

app = Flask(__name__)

# Config MySQL
app.config['MYSQL_HOST'] = 'localhost'
app.config['MYSQL_USER'] = '******'
app.config['MYSQL_PASSWORD'] = '******'
app.config['MYSQL_DB'] = 'flaskappdb'
app.config['MYSQL_UNIX_SOCKET'] = '/Applications/MAMP/tmp/mysql/mysql.sock'
app.config['MYSQL_CURSORCLASS'] = 'DictCursor'
# you can set key as config
app.config['GOOGLEMAPS_KEY'] = "8JZ7i18MjFuM35dJHq70n3Hx4"

# you can also pass the key here if you prefer
GoogleMaps(app, key="AIzaSyAFkMCq9GY2J9N-LDOlqCpBWDM1c4QwKbs")

geopy.geocoders.options.default_user_agent = 'my_app/1'
geopy.geocoders.options.default_timeout = 7
ctx = ssl.create_default_context(cafile=certifi.where())
geopy.geocoders.options.default_ssl_context = ctx
geolocator = Nominatim(scheme='http')

API_KEY = "AIzaSyAFkMCq9GY2J9N-LDOlqCpBWDM1c4QwKbs"
RETURN_FULL_RESULTS = False

# app.config['profile-images'] = '/Users/DRob/PycharmProjects/myflaskapp/static/profile-images'
app.config['profile-images'] = '/Users/DRob/sites/content/uploads'

# init MySQL
mysql = MySQL(app)