Giter Site home page Giter Site logo

codesamples's Introduction

Welcome to Knoxs Code Samples

I'm glad you're here

More to come!

codesamples's People

Contributors

dataknox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

codesamples's Issues

Dockerfile multiple CMD directives

Please remove duplicate CMD directives from Python/AppDev/Dockerfile

CMD ["ufw allow 5000"] .. this is just ignored, only last CMD is executed.

Why would you try to execute ufw inside a container? It's not available.

BTW directive MAINTAINER is depreciated.

Python/AppDev/app/myApi.py

This script actually fails to search beyond first entry in db.txt.
I've wasted 15 mins figuring out what's wrong, instead of learning :).

As you can see below, if first record is match, OK found.
If 1st record is not match, it will return with "No match".
2nd record is never tried, function never continues looping, it returns after validation of 1st record...

for record in records:
                if record['hostname'] == hostname:
                    LOG.info('Routers returned')
                    return jsonify(record), 200
                if record['hostname'] != hostname:
                    LOG.warning('No matching router')
                    return jsonify({"response": "No match"}), 200

I did modify your script to work:

@app.route('/routers', methods=['GET'])
def getRouter():
    try:
        hostname = request.args.get('hostname')
        if (hostname is None) or (hostname == ""):
            LOG.warning('No hostname specified')
            raise ValueError
        with open(f'{script_dir}/db.txt', 'r') as f:
            data = f.read()
            records = json.loads(data)
            for record in records:
                print("Hostname: ", record['hostname'])
                if record['hostname'] == hostname:
                    LOG.info('Routers returned')
                    return jsonify(record), 200
                if record['hostname'] != hostname:
                    continue    
                    
            LOG.warning('No matching router')
            return jsonify({"response": "No match"}), 200
    except ValueError:
        LOG.error("NO HOSTNAME SPECIFIED")
        return jsonify({"error": "NO_HOSTNAME_SPECIFIED"}), 400
    except Exception as err:
        LOG.error(f'Error during GET {err}')
        return jsonify({"error": err}), 500

Creating the repository gives an error in file installAnsible.py

Hello Knox,

First of all thank you for your clear instructions on CBT-nuggets!

I ran into an issue when I wanted to install ansible.
When I pasted in "sudo apt-add-repository ppa: ansible/ansible" I got the message "Error: need a single repository as argument". I searched online and came with an solution that helped me: between ppa: ansible/ansible there has to be no spaces in order to work. It worked for me when I used the command "sudo apt-add-repository ppa:ansible/ansible"

Kind regards.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.