Git Product home page Git Product logo

source-cloud-note's Introduction

作者的话

学了Django框架的部分知识,在学习的过程中,看到老师教了这个项目,但是非常的简陋,于是自己重新弄,想开发得更好一点,忙于找工作的原因,这个项目就暂时停在这里了,目前页面做得很简陋,整个网站也很小白,见谅……

项目部署

Debug=True

  1. 修改settings.py中的数据库配置,连接MySQL数据库。
CREATE DATABASE `库名` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
  1. 迁移模型到数据库:
python3 manage.py makemigrations
python3 manage.py migrate
  1. 运行项目:
python3 manage.py runserver

Debug=False

  1. 配置Web服务器以代理到Django应用程序。
  2. 配置静态文件的访问。
  3. 需要反复调试,保证网站正常运行。

源笔记界面

  1. 主页

image-20230604173633519

image-20230604173407826

  1. 注册页面

image-20230604173433531

  1. 登录页面

image-20230604173514636

image-20230604173549599

image-20230604173607521

  1. 笔记根目录

image-20230604173747682

  1. markdown笔记

image-20230604173844760

image-20230604173859088

项目开发大致流程

  1. 创建项目source_cloud_note

    django-admin startproject source_cloud_note
  2. 创建应用usernote

    python3 manage.py startapp user
    python3 manage.py startapp note
  3. 注册应用: 在settings.pyINSTALLED_APPS中添加usernote

  4. 配置分布式路由:

    • 当用户访问 http://127.0.0.1:8000/ 或者 http://127.0.0.1:8000/home 时,定义一个视图函数home返回。
    • 当用户访问以 http://127.0.0.1:8000/user 开头的功能时,使用user/urls.py继续进行功能的匹配。
    • 当用户访问以 http://127.0.0.1:8000/note 开头的功能时,使用note/urls.py继续进行功能的匹配。
  5. user应用和note应用添加模型。

    • 在MySQL数据库中创建数据库cloud_note,设置编码为utf8

      CREATE DATABASE `cloud_note` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
    • 修改settings.py中的数据库配置,连接MySQL数据库:

      'ENGINE': 'django.db.backends.mysql',
      'NAME': 'cloud_note',
      'USER': 'root',
      'PASSWORD': '',
      'HOST': '127.0.0.1',
      'PORT': 3306,
    • 将模型迁移到数据库:

      python3 manage.py makemigrations
      python3 manage.py migrate
  6. user应用下的urls.py中声明app_name

    • 当用户直接访问 http://127.0.0.1:8000/user/reg 时,定义一个视图函数reg_view处理请求。
    • 当用户直接访问 http://127.0.0.1:8000/user/login 时,定义一个视图函数login_view处理请求。
    • 当用户直接访问登录页面时,调用验证码 http://127.0.0.1:8000/user/api/call_captcha,定义一个视图函数captcha_api处理请求。
    • 当用户点击登录时,访问 http://127.0.0.1:8000/user/api/login,定义一个视图函数login_api处理请求。
    • 当用户点击退出时,访问 http://127.0.0.1:8000/user/api/logout,定义一个视图函数logout_api处理请求。
    • 配置模板目录:在templates下创建user目录保存所有和用户相关的模板。
  7. note应用下的urls.py中声明app_name

    • 当用户直接访问 http://127.0.0.1:8000/note/page 时,定义一个视图函数redirect_home处理请求,重定向到根目录笔记。
    • 当用户直接访问 http://127.0.0.1:8000/note/page/<int:foler_id> 时,定义一个视图函数home_view处理请求。
    • 当用户创建文件时,访问 http://127.0.0.1:8000/note/api/create_note,定义一个视图函数create_note_api处理请求。
    • 当用户创建文件夹时,访问 http://127.0.0.1:8000/note/api/create_folder,定义一个视图函数create_folder_api处理请求。
    • 当用户删除文件或者文件夹时,访问 http://127.0.0.1:8000/note/api/delete,定义一个视图函数delete_api处理请求。
    • 当用户重命名文件或者文件夹时,访问 http://127.0.0.1:8000/note/api/rename,定义一个视图函数rename_api处理请求。
    • 当用户修改笔记内容并保存时,访问 http://127.0.0.1:8000/note/api/content/modify,定义一个视图函数modify_content_api处理请求。

感谢

  1. Python
  2. Django
  3. jQuery
  4. Editor.md

source-cloud-note's People

Contributors

gupingan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.