Browse Source

fin-v0

master
= 4 years ago
parent
commit
84d8c87e73
10 changed files with 36 additions and 12 deletions
  1. BIN
      APP/static/img/10f90d1a-86fd-4382-953e-45bd44bf4b93.png
  2. BIN
      APP/static/img/f83bbd79-4641-41cb-9f7f-d6a35dbe1aac.png
  3. +8
    -2
      APP/static/js/wsy.js
  4. +2
    -2
      APP/templates/personal.html
  5. +2
    -2
      APP/templates/square.html
  6. BIN
      APP/view/__pycache__/block.cpython-37.pyc
  7. BIN
      APP/view/__pycache__/database.cpython-37.pyc
  8. BIN
      APP/view/__pycache__/start.cpython-37.pyc
  9. +23
    -5
      APP/view/block.py
  10. +1
    -1
      APP/view/database.py

BIN
APP/static/img/10f90d1a-86fd-4382-953e-45bd44bf4b93.png View File

Before After
Width: 250  |  Height: 244  |  Size: 9.8 KiB

BIN
APP/static/img/f83bbd79-4641-41cb-9f7f-d6a35dbe1aac.png View File

Before After
Width: 257  |  Height: 222  |  Size: 4.8 KiB

+ 8
- 2
APP/static/js/wsy.js View File

@ -134,7 +134,7 @@ function getContent(type) {
page.textList[i]['order'] = i;
if (type == 'block' && page.textList[i]['type'] == 'picture') {
console.log(page.textList[i]);
page.textList[i]['content'] = get_url(page.textList[i]['content']);
// page.textList[i]['content'] = get_url(i);
}
}
@ -178,13 +178,19 @@ async function checkLike(list) {
}
}
function get_url(f) {
function get_url(i) {
var data = new FormData();
data.append('pic',page.textList[i]['content']['$binary']);
sendRequest('block/get_pic',data,function(f){
console.log(f);
let reader = new FileReader();
console.log(f);
reader.readAsDataURL(f);
reader.onload = function (e) {
return e.target.files[0] || e.dataTransfer.files[0];
};
})
}

+ 2
- 2
APP/templates/personal.html View File

@ -423,14 +423,14 @@
<ul class="vertical-nav-menu">
<li class="app-sidebar__heading">个人中心</li>
<li>
<a href="%%url_for('start.personal')%%" class="mm-active">
<a href="/personal" class="mm-active">
<i class="metismenu-icon pe-7s-browser">
</i>我的集锦
</a>
</li>
<li class="app-sidebar__heading">广场</li>
<li>
<a href="%%url_for('start.square')%%">
<a href="/square">
<i class="metismenu-icon pe-7s-display2">
</i>用户集锦
</a>

+ 2
- 2
APP/templates/square.html View File

@ -39,7 +39,7 @@
// wsy:这个phonenum可能需要用什么传参的方式得到
var phonenum = cookie.getCookie("phonenum");
if(phonenum == ""){
window.location.href = "login.html";
window.location.href = "/login";
//phonenum = "1";
}
@ -368,7 +368,7 @@
<ul class="vertical-nav-menu">
<li class="app-sidebar__heading">个人中心</li>
<li>
<a href="personal.html">
<a href="\personal">
<i class="metismenu-icon pe-7s-browser">
</i>我的集锦
</a>

BIN
APP/view/__pycache__/block.cpython-37.pyc View File


BIN
APP/view/__pycache__/database.cpython-37.pyc View File


BIN
APP/view/__pycache__/start.cpython-37.pyc View File


+ 23
- 5
APP/view/block.py View File

@ -1,12 +1,15 @@
from flask import Flask, render_template, request, jsonify, session, Blueprint
from flask import Flask, render_template, request, jsonify, session, Blueprint ,send_file
from bson import json_util
import uuid
import os
import io
from PIL import Image
from APP.view.database import db_session
from APP.view.model import Block, CollectionBlock
bp_block = Blueprint("block", __name__, url_prefix="/block")
basedir = os.path.abspath('.')
@bp_block.route("/add", methods=["POST"])
def add_block():
@ -22,8 +25,12 @@ def add_block():
content = request.form.get("content")
b = Block(type=type, content_text=content, order=count, id=id)
else:
content = request.files.get("content")
b = Block(type=type, content_pic=content, order=count, id=id)
img = request.files.get("content")
print(img)
path = basedir + "/APP/static/img/"
file_path = path + id + '.png'
img.save(file_path)
b = Block(type=type, content_text='static/img/'+id+'.png', order=count, id=id)
db_session.add(b)
cb = CollectionBlock(id=collection_id, block_id=id)
db_session.add(cb)
@ -60,7 +67,7 @@ def get_block():
if item.type == 'url' or item.type == 'text':
block_tmp['content'] = item.content_text
else:
block_tmp['content'] = item.content_pic
block_tmp['content'] = item.content_text
block_tmp['order'] = item.order
blocks.append(block_tmp)
except BaseException as e:
@ -172,3 +179,14 @@ def get_web_name():
"""
return json_util.dumps(ret)
@bp_block.route("/get_pic", methods=["POST"])
def get_pic():
img = bytes(request.form.get('pic'), encoding = "utf8")
byte_stream = io.BytesIO(img)
im2 = Image.open(byte_stream)
ret = {'msg': 'succuss'}
im2.save(request.form.get('pic')[20:]+".gif", "GIF")
ret['url'] = request.form.get('pic')[20:]+".gif"
return ret

+ 1
- 1
APP/view/database.py View File

@ -16,4 +16,4 @@ def init_db():
Base.metadata.drop_all(bind=engine)
Base.metadata.create_all(bind=engine)
init_db()
#init_db()

Loading…
Cancel
Save