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

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -