Beispiel #1
0
def create_app(username, password, matrikkel_url, matrikkel_user, matrikkel_pass):
    app = Flask(__name__)

    app.config["BASIC_AUTH_FORCE"] = True
    app.config["BASIC_AUTH_USERNAME"] = username
    app.config["BASIC_AUTH_PASSWORD"] = password

    create_api(app, API_VERSION, matrikkel_url, matrikkel_user, matrikkel_pass)
    if not app.debug:
        stream_handler = StreamHandler()
        app.logger.addHandler(stream_handler)

    return app
Beispiel #2
0
    def setUp(self):
        app = Flask(__name__)

        app.config["BASIC_AUTH_USERNAME"] = "john"
        app.config["BASIC_AUTH_PASSWORD"] = "matrix"

        basic_auth = BasicAuth(app)

        @app.route("/")
        def normal_view():
            return "This view does not normally require authentication."

        @app.route("/protected")
        @basic_auth.required
        def protected_view():
            return "This view always requires authentication."

        self.app = app
        self.basic_auth = basic_auth
        self.client = app.test_client()
Beispiel #3
0
def create_app(cfg):
    """
    Application factory function

    :param cfg: dict
        Configuration parameters

    :return: app
    """
    app = Flask(__name__)

    from .api import api

    app.register_blueprint(api)

    # By default this sets CORS access to resource endpoints to `*`
    app.config["BASIC_AUTH_USERNAME"] = cfg["api"]["username"]
    app.config["BASIC_AUTH_PASSWORD"] = cfg["api"]["password"]

    # Enable CORS Configuration and Basic Authentication
    cors = CORS(app)
    api = Api(app)

    return app
Beispiel #4
0
# https://flask-basicauth.readthedocs.org/en/latest/
# https://flask-restful.readthedocs.org/en/latest/index.html
# https://github.com/miguelgrinberg/REST-auth
# https://github.com/miguelgrinberg/REST-tutorial/blob/master/rest-server-v2.py

from flask import Flask, request, make_response, jsonify, abort
from flask_restful import Resource, Api, reqparse
from flask.ext.basicauth import BasicAuth
import json
from sqlalchemy import create_engine

db = create_engine("sqlite:///servers.db")
app = Flask(__name__)
api = Api(app)
app.config["BASIC_AUTH_USERNAME"] = "demo"
app.config["BASIC_AUTH_PASSWORD"] = "demo"
basic_auth = BasicAuth(app)


def router_exists(router):
    conn = db.connect()
    query = conn.execute("select count(*) from servers where server='%s'" % router.lower()).fetchone()
    if query[0] == 1:
        return True


# PUBLIC API QUERIES
class All(Resource):  # returns the full list of routers
    def get(self):
        conn = db.connect()
        query = conn.execute("select server,port,type from servers")
Beispiel #5
0
Datei: app.py Projekt: sopnic/ybk
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging

from flask import Flask, render_template, request, jsonify
from flask.ext.basicauth import BasicAuth

from trademanager import TradeManager, tops, names

app = Flask(__name__)

app.config["BASIC_AUTH_USERNAME"] = "ybk369"
app.config["BASIC_AUTH_PASSWORD"] = "ybk888"

basic_auth = BasicAuth(app)
tm = TradeManager()


@app.route("/")
@basic_auth.required
def index():
    symbol = request.args.get("symbol", "100001")
    namedict = {i["username"]: i["name"] for i in tm.investors}
    return render_template("index.html", tops=tops, names=names, namedict=namedict, symbol=symbol)


@app.route("/update.ajax")
def update():
    symbol = request.args.get("symbol", "100001")
    tm.sync(symbol)
    if symbol not in tm.prices:
from flask import Flask, render_template, redirect, request
from flask.ext.basicauth import BasicAuth
import os
import sys
import ConfigParser

app = Flask(__name__)

#############################
# Password Protection       #
#############################

app.config["BASIC_AUTH_USERNAME"] = "ouss"
app.config["BASIC_AUTH_PASSWORD"] = "pass"

basic_auth = BasicAuth(app)


@app.route("/")
@basic_auth.required
def secret_view():
    return redirect("/home", code=302)


#############################
# Home page / start / stop  #
#############################


def fail2banStatus():
    f = os.popen("service fail2ban status")
from flask import Flask, make_response, render_template, request, redirect, url_for
import collect_follower_count
import turk_functions
import collect_like_decay
from flask.ext.basicauth import BasicAuth
from hashlib import sha512
import datetime as dt

app = Flask(__name__)
app.secret_key = sha512("cybersec").hexdigest()
app.config["BASIC_AUTH_USERNAME"] = "groupthinkmanager"
app.config["BASIC_AUTH_PASSWORD"] = "accounts"

env = app.jinja_env
env.line_statement_prefix = "="

basic_auth = BasicAuth(app)


@app.route("/", methods=["GET", "POST"])
@basic_auth.required
def index():
    if request.method == "POST":
        if "account_list" in request.form:
            raw_account_string = request.form["account_list"]
            if raw_account_string != "":
                account_list = request.form["account_list"].split(",")
                for account in account_list:
                    collect_follower_count.add_username(account)
        elif "like_account_list" in request.form:
            raw_account_string = request.form["like_account_list"]
Beispiel #8
0
from DAOs.gamesDAO import GameDAO
from DAOs.killsDAO import KillDAO
from DAOs.playersDAO import PlayerDAO
from DAOs.userDAO import UserDAO
from Models.kills import *
from Models.players import *
from Models.user import *
from Service.GameService import *


# hello.py serves as a config file that routes all HTTP traffic to appropriate functions/methods
app = Flask(__name__)

# app configs for BasicAuth.local accepted user/pass only set at registration, which is NOt protected
app.config["BASIC_AUTH_USERNAME"] = "specialkeythatnoonewilleverknow"
app.config["BASIC_AUTH_PASSWORD"] = "specialerpasswordisawesome"
basic_auth = BasicAuth(app)

# DAO initialization for easy access
playerDAO = PlayerDAO()
usersDAO = UserDAO()
killsDAO = KillDAO()
gameDAO = GameDAO()


@app.route("/")
def index():
    return "Welcome to Ronak's Mafia Game Web Service. Please register/login."

Beispiel #9
0
# Copyright 2015 elastic-search-api authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.

import json
import os
import requests
from flask import Flask, request
from flask.ext.basicauth import BasicAuth


app = Flask(__name__)

app.config["BASIC_AUTH_USERNAME"] = os.environ.get("ES_BROKER_USERNAME", "admin")
app.config["BASIC_AUTH_PASSWORD"] = os.environ.get("ES_BROKER_PASSWORD", "password")

basic_auth = BasicAuth(app)
app.config["BASIC_AUTH_FORCE"] = True

ELASTICSEARCH_HOST = os.environ.get("ELASTICSEARCH_HOST")
ELASTICSEARCH_PORT = os.environ.get("ELASTICSEARCH_PORT", "9200")


@app.route("/resources/plans", methods=["GET"])
def plans():
    plans = [{"name": "shared_data", "description": "shared elasticsearch server"}]
    return json.dumps(plans), 200


@app.route("/resources", methods=["POST"])
def add_instance():
Beispiel #10
0
# System imports
from flask import Flask
from flask.ext.basicauth import BasicAuth

# local imports
from DbSchema import DbSchema

app = Flask(__name__)
app.debug = True

app.config.update(DB_HOST="127.0.0.1", DB_USER="root", DB_PASSWORD="hackme", DB_NAME="employees", DB_PORT="3306")

app.config["BASIC_AUTH_USERNAME"] = "user"
app.config["BASIC_AUTH_PASSWORD"] = "password"

basic_auth = BasicAuth(app)


@app.route("/")
@basic_auth.required
def root():
    return "Hello"


@app.route("/columns/<t>")
@basic_auth.required
def get_column(t):
    return ",".join(app.config["SCHEMA"].getColumns(t))


if __name__ == "__main__":
Beispiel #11
0
def compileBreadcrumbs(title):
    title = title.split("/")
    href = ""
    breadcrumbs = []
    for part in title:
        href += "/" + part
        breadcrumbs.append({"href": href, "part": part})
    return breadcrumbs


app = Flask(__name__)
app.config["SECRET_KEY"] = "MimirIsNotSecure"

if config.get("security", "password") != "":
    app.config["BASIC_AUTH_USERNAME"] = config.get("security", "username")
    app.config["BASIC_AUTH_PASSWORD"] = config.get("security", "password")
    app.config["BASIC_AUTH_REALM"] = "Mímir is password protected"
    app.config["BASIC_AUTH_FORCE"] = True
    BasicAuth(app)


@app.route("/app")
def onePageApp():
    return render_template("app.html", title="Mímir")


@app.route("/", methods=["GET", "POST"])
@app.route("/+<format>", methods=["GET", "POST"])
@app.route("/<path:filename>", methods=["GET", "POST"])
@app.route("/<path:filename>+<format>", methods=["GET", "POST"])
Beispiel #12
0
#!/usr/bin/python3
from flask import Flask, session, redirect, escape, request, render_template, url_for
from flask_socketio import SocketIO
import os
import argparse
import sys
from arm_interface import ArmInterface
from flask.ext.basicauth import BasicAuth

# import uuid
import players
from werkzeug.routing import RequestRedirect

app = Flask(__name__, static_folder="static")
# Auth
app.config["BASIC_AUTH_USERNAME"] = "john"
app.config["BASIC_AUTH_PASSWORD"] = "matrix"
basic_auth = BasicAuth(app)
socketio = SocketIO(app)

# Connect to Arm
# arm = ArmInterface()
# arm.begin_connection()

global_list = {}

current_players = players.Players()


# Routing
@app.route("/")
Beispiel #13
0
import os, sys
from flask import Flask, render_template, request, redirect, url_for
from flask.ext.basicauth import BasicAuth
from werkzeug import secure_filename
from os import path

app = Flask(__name__)

UPLOAD_FOLDER = "/path/to/the/uploads"
ALLOWED_EXTENSIONS = set(["gpx"])

app.config["BASIC_AUTH_USERNAME"] = "hawaii"
app.config["BASIC_AUTH_PASSWORD"] = "trails"
app.config["UPLOAD_FOLDER"] = UPLOAD_FOLDER


def track_list():
    path = os.getcwd() + "/static/gpx/"
    files = []
    dirs = os.listdir(path)
    for file in dirs:
        files.append(file)
    return files


track_list = track_list()


@app.route("/")
def index():
    return render_template("layout.html", files=track_list)
Beispiel #14
0
import MySQLdb
import collections
from logging.handlers import RotatingFileHandler
import json
import ast
from datetime import *
from types import *

#
sys.path.insert(0, "./static/python")
from socool_utils import *
from forms import opdDeploymentForm

app = Flask(__name__)
app.config.from_object("config")
app.config["BASIC_AUTH_USERNAME"] = "oceantech"
app.config["BASIC_AUTH_PASSWORD"] = "m0t3_ot"
basic_auth = BasicAuth(app)

# routes
@app.route("/login/opd/deploy/update", methods=["POST"])
@basic_auth.required
def update():

    conn = connect_db_socool()
    cursor = conn.cursor(MySQLdb.cursors.DictCursor)

    serial = int(request.form["serial"])
    operator = request.form["operator"]
    deployed = request.form["deployed"]
    site = request.form["site"]
Beispiel #15
0
#!/usr/bin/env python
# coding: utf-8

from flask import Flask
from flask.ext.basicauth import BasicAuth
from flask_pybankid import PyBankID
import os

app = Flask(__name__)

app.config["BASIC_AUTH_USERNAME"] = os.getenv("USR")
app.config["BASIC_AUTH_PASSWORD"] = os.getenv("PASS")
app.config["BASIC_AUTH_FORCE"] = True

basic_auth = BasicAuth(app)

app.config.from_object("server.config")
bankid = PyBankID(app)
import json
import re

import database

# import flask stuff
from flask import Flask
from flask import Response
from flask import request
from flask import render_template
from flask import make_response
from flask.ext.basicauth import BasicAuth

app = Flask(__name__, static_url_path="")

app.config["BASIC_AUTH_USERNAME"] = "hfadmin"
app.config["BASIC_AUTH_PASSWORD"] = "hfadmin"

basic_auth = BasicAuth(app)


@app.route("/")
def newteam():
    data = {}
    return render_template("newteam.html")


@app.route("/admin")
@basic_auth.required
def admin():
    tf2 = []
from openfecwebapp.config import port, debug, host, api_location, username, password, debug
from flask import Flask, render_template, request
from flask.ext.basicauth import BasicAuth
from openfecwebapp.views import render_search_results, render_table, render_page
from openfecwebapp.api_caller import load_search_results, load_single_type, load_single_type_summary, install_cache

import sys
import locale

locale.setlocale(locale.LC_ALL, "")

app = Flask(__name__)

app.jinja_env.globals["api_location"] = api_location

app.config["BASIC_AUTH_USERNAME"] = username
app.config["BASIC_AUTH_PASSWORD"] = password
app.config["BASIC_AUTH_FORCE"] = True

basic_auth = BasicAuth(app)


def _convert_to_dict(params):
    """ move from immutablemultidict -> multidict -> dict """
    params = params.copy().to_dict()
    params = {key: value for key, value in params.items() if value}
    return params


@app.route("/")
def search():
Beispiel #18
0
from flask import Flask, render_template, url_for, request, Response, redirect, flash, jsonify, make_response
from flask import session as motorSwitch
from flask.ext.basicauth import BasicAuth
from datetime import timedelta
from flask import make_response, request, current_app
import motor
import os
from thread import start_new_thread
from flask.ext.cors import CORS
import subprocess
import requests

app = Flask(__name__)
cors = CORS(app, resources={r"/api/*": {"origins": "*"}})
APPLICATION_NAME = "mikeBot"
app.config["BASIC_AUTH_USERNAME"] = "test"
app.config["BASIC_AUTH_PASSWORD"] = "test"

basic_auth = BasicAuth(app)


def startStream():

    subprocess.call(
        'export LD_LIBRARY_PATH=. ; ./mjpg_streamer -o "output_http.so -w ./www" -i "input_raspicam.so -x 640 -y 480 -fps 15 -vf -hf"',
        shell=True,
        cwd="/var/www/mjpg-streamer/mjpg-streamer-experimental",
    )


@app.route("/", methods=["GET", "POST"])
Beispiel #19
0
import os
from flask import Flask, render_template, send_from_directory, request, flash, redirect, url_for
from flask.ext.basicauth import BasicAuth

app = Flask(__name__)

app.secret_key = "notemetaipo"
app.CSRF_ENABLED = True
app.WTF_CSRF_SECRET_KEY = "*YQUIHDHQYP#*p94uUOI"

app.config.update(DEBUG=True)

app.config["BASIC_AUTH_USERNAME"] = "teralytics"
app.config["BASIC_AUTH_PASSWORD"] = ""
basic_auth = BasicAuth(app)


@app.errorhandler(404)
def page_not_found(e):
    return render_template("404.html"), 404


@app.route("/", methods=["GET", "POST"])
def index():
    return render_template("index.html")


@app.route("/basics", methods=["GET", "POST"])
@basic_auth.required
def basics():
    return render_template("basics.html")
Beispiel #20
0
# Imports
import os

# Flask imports
from flask import Flask
from flask.ext.basicauth import BasicAuth

# Initialize app
app = Flask(__name__)
app.config["DEBUG"] = True
app.config["JSDOC_FOLDER"] = "/static/jsdoc/"

# Get name & pass from env
app.config["BASIC_AUTH_USERNAME"] = os.environ.get("CITELET_AUTH_USERNAME")
app.config["BASIC_AUTH_PASSWORD"] = os.environ.get("CITELET_AUTH_PASSWORD")

# Set up authentication
basic_auth = BasicAuth(app)

# Import views
from views import *
from docviews import *

# Main
if __name__ == "__main__":

    # Start Flask app
    app.run()