python - Writing to a file from a Flask Server -
i writing small application. pretty small 1 learn new technologies.( angular -- front end) , flask server side . in server, have store users info in file. file has usernames , passwords. have tried : ( not working ):
f=open('userinfo.txt','w') f.write(app.users) f.close()
here store username , password in app.users dictionary.
app= flask(__name__) app.users={}
these 2 lines show dictionary part.
how can store usernames , passwords in file. how can implement this. help. tutorials can learn.
storing usernames , passwords in file may not best idea cannot write dictionary file can write strings file. example assume app.users
dictionary in format {username: password}
import os open('userinfo.txt', 'w') users_file: username, password in app.users.items() users_file.write(username + ',' + password + os.linesep)
Comments
Post a Comment