Total Pageviews

Thursday 9 August 2018

博客程序:python-webapp


python license
这是Python教程 - 廖雪峰的官方网站中的一个博客实战项目,供学习使用。

项目结构

python-webapp/           <-- 根目录
|
+- backup/               <-- 备份目录
|
+- conf/                 <-- 配置文件
|
+- dist/                 <-- 打包目录
|
+- www/                  <-- Web目录,存放.py文件
|  |
|  +- static/            <-- 存放静态文件
|  |
|  +- templates/         <-- 存放模板文件
|
+- ios/                  <-- 存放iOS App工程
|
+- LICENSE               <-- LICENSE

运行

本地预览(请保证已安装MySQL --> Mac安装教程):
$ git clone https://github.com/WeiLeiming/python-webapp.git
$ cd python-webapp
$ pip3 install -r requirements.txt
$ cd www
$ mysql -u root -p < schema.sql
$ chmod +x pymonitor.py
$ ./pymonitor.py app.py
浏览器访问http://localhost:9000/

开发环境

  • Python 3.6.2
  • MySQL Community Server 5.7.19
  • 第三方库
    • aiohttp - Async http client/server framework (asyncio)
    • jinja2 - a template engine written in pure Python
    • aiomysql - aiomysql is a library for accessing a MySQL database from the asyncio
    • uikit — A lightweight and modular front-end framework for developing fast and powerful web interfaces
    • Vue.js — A progressive, incrementally-adoptable JavaScript framework for building UI on the web.

开发工具

总结

用户浏览页面:

  • 首页:GET /
  • 注册页:GET /register
  • 登录页:GET /signin
  • 日志详情页:GET /blog/{id}

管理页面:

  • 评论列表页:GET /manage/comments
  • 日志列表页:GET /manage/blogs
  • 用户列表页:GET /manage/users
  • 创建日志:GET /manage/blogs/create
  • 修改日志:GET /manage/blogs/edit

后台API:

  • 注册用户:POST /api/users
  • 验证用户:POST /api/authenticate
  • 获取用户:GET /api/users
  • 退出用户:GET /signout
  • 创建日志:POST /api/blogs
  • 获取详情日志:GET /api/blogs/{id}
  • 获取日志:GET /api/blogs
  • 修改日志:POST /api/blogs/{id}
  • 删除日志:POST /api/blogs/{id}/delete
  • 创建评论:POST /api/blogs/{id}/comments
  • 获取评论:GET /api/comments
  • 删除评论:POST /api/comments/{id}/delete

参考


from  https://github.com/WeiLeiming/python-webapp

No comments:

Post a Comment