예제 #1
0
class TesteUserModel(TestCase):
    data = {
        "login": "******",
        "password": "******",
        "city": "Curitiba"
    }

    new_login = "******"
    new_password = "******"
    new_city = "São paulo"

    users = Users()
    user = User()
    user_register = UserRegister()
    user_update = UserUpdate()
    user_login = UserLogin()

    @app.route('/users')
    def test_list_users(self):
        assert self.users.get()

    with app.test_client() as client:
        response = client.get('/users')
        data = json.load(response.data)
        print
class TesteUserModel(TestCase):
    data = {
        "login": "******",
        "password": "******",
        "city": "Curitiba"
    }

    new_login = "******"
    new_password = "******"
    new_city = "São paulo"

    users = Users()
    user = User()
    user_register = UserRegister()
    user_update = UserUpdate()
    user_login = UserLogin()

    #     @app.route('/users')
    #     def test_list_users():
    #         print('test')
    #         # assert self.users.get()

    # # if __name__ == '__main__':
    # with app.test_client() as client:
    #     client.get('/users')@app.route('/')
    def hello():
        print('during view')
        return 'Hello, World!'

    @app.teardown_request
    def show_teardown(exception):
        print('after with block')
class TesteUserModel(TestCase):
    data = {
        "login": "******",
        "password": "******",
        "city": "Curitiba"
    }

    new_login = "******"
    new_password = "******"
    new_city = "São paulo"

    users = Users()
    user = User()
    user_register = UserRegister()
    user_update = UserUpdate()
    user_login = UserLogin()

    @app.route('/users')
    def test_list_users(self):
예제 #4
0
app = Flask(__name__)
app.config['BUNDLE_ERRORS'] = True
api = Api(app)
CORS(app)

# JWT configs
app.config['JWT_SECRET_KEY'] = environ.get('JWT_SECRET_KEY', 'default')
app.config['JWT_ACCESS_TOKEN_EXPIRES'] = timedelta(minutes=2)
app.config['JWT_REFRESH_TOKEN_EXPIRES'] = environ.get(
    'JWT_REFRESH_EXPIRATION', False)
jwt = JWTManager(app)

# Module object initiaization
features = Features()
apps = Apps()
users = Users()
tokens = Tokens()
groups = Groups()
# Arguments parsing
parser = reqparse.RequestParser()

parser.add_argument('user', type=str,  required=True,
                    help='Missing <<user>> parameter')
parser.add_argument('password', type=str,  required=True,
                    help='Missing <<password>> parameter')


@app.before_first_request
def set_default_user():
    # Creates a default user if there is not any user
    users._set_default_user()
예제 #5
0
파일: app.py 프로젝트: todpunk/tnlfalcon

class StaticResource(object):
    def on_get(self, req, resp, filename):
        # do some sanity check on the filename
        resp.status = falcon.HTTP_200
        with open('static/' + filename, 'r') as f:
            resp.body = f.read()


class IndexResource(object):
    def on_get(self, req, resp):
        resp.status = falcon.HTTP_200
        resp.content_type = 'text/html'
        with open('static/index.html', 'r') as f:
            resp.body = f.read()


api = falcon.API(middleware=[
    # TransactionStarter(),
    AuthMiddleware(),
    CORSComponent(),
])

api.add_route('/', IndexResource())
api.add_route('/static/{filename}', StaticResource())
api.add_route('/sessions', Sessions())
api.add_route('/sessions/{id:int(None,1)}', Sessions())
api.add_route('/users', Users())
api.add_route('/users/{id:int(None,1)}', Users())