I'm glad you're here
More to come!
CBT Nuggets course code samples
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.
cannot connect, related to a PR that is ope
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
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.