All the code from my YouTube videos organized by date.
My YouTube channel is here: https://youtube.com/c/prettyprintedtutorials
The code for all the YouTube videos I publish on YouTube.
License: The Unlicense
All the code from my YouTube videos organized by date.
My YouTube channel is here: https://youtube.com/c/prettyprintedtutorials
I followed the Youtube tutorial and for some reason I keep coming up with the following error
TypeError: type object argument after ** must be a mapping, not str
I used a different JSON generator but everything worked until I tried to loop through the Users and append their details to the user_list. The code is below for reference, any help on this would be much appreciated:
import os
os.chdir(r'C:\Users\robbi\Desktop\Coding\My Python Scripts\APIs')
class User:
def __init__(self, gender, name, location, email, login, dob, registered, phone, cell, id, picture, nat):
self.gender = gender
self.title = name['title']
self.first_name = name['first']
self.last_name = name['last']
self.location = location['city']
self.email = email
self.username = login['username']
self.password = login['password']
self.dob = dob['date']
self.age = dob['age']
self.registered = registered['date']
self.phone = phone
self.cell = cell
self.id = id['value']
self.picture = picture['large']
self.nat = nat
@classmethod
def from_json(cls, json_string):
json_dict = json.loads(json_string)
return cls(**json_dict)
def __repr__(self):
return f'<User { self.first_name }>'
json_string = '''{
"gender":"female",
"name":{
"title":"Miss",
"first":"Maeva",
"last":"Gagnon"
},
"location":{
"street":{
"number":3400,
"name":"3rd St"
},
"city":"Belmont",
"state":"Nunavut",
"country":"Canada",
"postcode":"N5J 3K1",
"coordinates":{
"latitude":"-60.0772",
"longitude":"148.5555"
},
"timezone":{
"offset":"+11:00",
"description":"Magadan, Solomon Islands, New Caledonia"
}
},
"email":"[email protected]",
"login":{
"uuid":"b51f5119-d542-4c59-8ed1-11d257a6dd1a",
"username":"beautifulbird203",
"password":"sinned",
"salt":"vqkYxMd6",
"md5":"f2f79890187d94eabbba380c59c29ca2",
"sha1":"2ce9a4227ca1717b45a99cb1f12fdef57486258a",
"sha256":"106b7af161a58f6c5f08d2c0ce337ff0f8d978816f09dcbef082efd11c71ac44"
},
"dob":{
"date":"1989-09-17T06:18:26.692Z",
"age":31
},
"registered":{
"date":"2004-11-14T22:10:48.600Z",
"age":16
},
"phone":"464-880-6563",
"cell":"560-036-0580",
"id":{
"name":"",
"value":null
},
"picture":{
"large":"https://randomuser.me/api/portraits/women/32.jpg",
"medium":"https://randomuser.me/api/portraits/med/women/32.jpg",
"thumbnail":"https://randomuser.me/api/portraits/thumb/women/32.jpg"
},
"nat":"CA"
}'''
#user = User.from_json(json_string)
#print(user)
users_list = []
with open('data.json', 'r') as json_file:
user_data = json.loads(json_file.read())
for u in user_data:
users_list.append(User(**u))
print(users_list)
Hey man, I cannot find the source code of this valuable video you made https://www.youtube.com/watch?v=I2dJuNwlIH0 .
Can you point out where it is?
Thank you
We change the MIME-type? But I didnt find MIME type associated with Excel?
Hi,
I am trying to send a reset email but the problem is whenever I try to trigger an email it is a bit slow it takes at least 5-10 sec to trigger the email. I also tried to do multi-threading but that dint work. Is there is a problem with my SMTP provider or any problem with my code?
I am using Hostinger as my SMTP.
Can you suggest to me a good SMTP provider
def forgetPasswordMail(email,token,msg,link):
msg.body = 'Your link is {}'.format(link)
mail.send(msg)
token = s.dumps(email, salt='forget-password')
msg = Message('Reset Password', sender='[email protected]', recipients=[email])
link = url_for('reset_password', token=token, _external=True)
start_new_thread(forgetPasswordMail,(email,token,msg,link))
Hello, under what license is this project released under ? I would like to learn Flask by studying them and your Youtube videos. Thank-you for making them.
Hey, just wanted to let you know that there's an option to 'Delete Directory' popping up on the 'Testing In Flask'. Probably shouldn't be there
I just started to learn flask, and you are the best resource on the internet. Whatever, I think of, you have the video and examples. Thank you and really appreciate that.
I just started a project where I have two python classes, one is model.py and second is the application.py. The model.py contains the model and application contains routes. Now when I try to use Admin views I have the following error.
AttributeError: type object 'Programs' has no attribute '_query_cls'
This is the code in application.py
app.config["SQLALCHEMY_DATABASE_URI"] = "postgresql://junaid:junaid@localhost:5432/UOB"
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
app.config['SECRET_KEY']= 'junaid'
db.init_app(app)
admin = Admin(app)
admin.add_view(ModelView(Programs,db.Session))
Application runs without error, when naviated to /admin/Programs I received the above mentioned error. I will be really thankful if you could help, please.
trying to run the youtube flask app and im getting a key error for line 26 in routes.py results = r.json()['items']
I am using the below command and it is throwing an error -
flask --app .\app.py --debug run
The Error -
` * Tip: There are .env or .flaskenv files present. Do "pip install python-dotenv" to use them.
Usage: flask run [OPTIONS]
Try 'flask run --help' for help.
Error: Failed to find Flask application or factory in module 'login_app_demo.app'. Use 'login_app_demo.app:name' to specify one.`
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.