简体   繁体   English

如何使用 Django 在本地机器上创建目录/文件?

[英]How to create directories/files on the local machine using Django?

I'm working on a blockchain project where I'm implementing a wallet using Django. A user logs in and get's to generate an address.我正在从事一个区块链项目,我正在使用 Django 实现一个钱包。用户登录并生成一个地址。 Now, I want to store the user's private key/public key pair in a file locally on the user's machine every time a user generates an address, and be able to read that file again in the next session (at the user's will).现在,我想在每次用户生成地址时将用户的私钥/公钥对存储在用户机器本地的文件中,并能够在下一个 session 中再次读取该文件(根据用户的意愿)。 I'm doing this because the app itself is a supernode of the blockchain and all users are virtual nodes.我这样做是因为应用程序本身是区块链的超级节点,所有用户都是虚拟节点。 All communication between users happen through the supernode, thus the wallet functionality isn't the core function of the app.用户之间的所有通信都通过超级节点进行,因此钱包功能不是应用程序的核心 function。

Everything is working perfectly except I can't find a way to create files locally on the client's machine.除了我找不到在客户端机器上本地创建文件的方法外,一切都运行良好。 I've perused the Django documentation but I can't seem to find anything useful (maybe I'm not looking in the right place).我仔细阅读了 Django 文档,但我似乎找不到任何有用的东西(也许我没有找对地方)。

Is there a way I can achieve that?有什么办法可以实现吗?

Note: I'm trying as much as possible to avoid JavaScript, and I don't want users to download/upload files manually.注意:我尽量避免使用 JavaScript,我不希望用户手动下载/上传文件。

Saveing data/files on the clients machine is restricted but modern browser for good (security) reason.出于良好(安全)的原因,在客户端计算机上保存数据/文件受到限制,但现代浏览器。 However there are Cookies ( https://www.w3schools.com/js/js_cookies.asp , https://docs.djangoproject.com/en/3.2/topics/http/sessions/ ) or html5 webstorage ( https://www.w3schools.com/html/html5_webstorage.asp ).但是有 Cookies ( https://www.w3schools.com/js/js_cookies.asp , https://docs.djangoproject.com/en/3.2/topics/http/sessions/ ) 或 html5 webstorage ( 865205 (865205 ) www.w3schools.com/html/html5_webstorage.asp )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Django无法在服务器上找到静态文件,但在本地计算机上可以正常工作 - Django cant find static files on server, but works fine on local machine 如何使用 python 在谷歌驱动器中创建目录? - How to create directories in google drive using python? 是否可以使用 GitLab CI 将文件写入您的机器(本地驱动器)? - Is it possible to write files to your machine (local drive) using GitLab CI? 在Django / Mezzanine中使用本地MathJax文件 - Using local MathJax files with Django / Mezzanine 如何在 Django 中设置本地文件和生产文件 - How do I set up local files and production files in Django 无法在本地机器上运行 Django 项目 - Not able to run Django project on local machine 一种无需覆盖即可创建文件和目录的方法 - A way to create files and directories without overwriting 从多个目录中的 txt 文件创建 dict - Create dict from txt files in multiple directories 如何将 Django web 应用程序从本地机器迁移到另一台机器[没有互联网; 不能使用 PIP] 作为可部署的应用程序 - How to migrate a Django web app from local machine to another machine[with no internet; can't use PIP] as deployable app 如何创建一个文件对话框,返回所选文件和目录的文件路径? - How to create a file dialog that returns file paths for both selected files AND directories?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM