This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
import hashlib | |
import requests | |
import shutil | |
email = "[email protected]" | |
image_path = "/tmp/example.png" | |
gravatar_url = "http://www.gravatar.com/avatar/" + hashlib.md5( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 用于view的装饰器 | |
from ..utils.permissions import VisitorPermission | |
@bp.route('/signin', methods=['GET', 'POST']) | |
@VisitorPermission() | |
def signin(): | |
"""登陆""" | |
form = SigninForm() | |
if form.validate_on_submit(): | |
signin_user(form.user) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
from flask import request, g | |
from functools import wraps | |
from flask import abort, session, redirect, url_for, flash | |
from .models import Topic, Attachment | |
from . import roles | |
def require_visitor(func): | |
"""仅允许非登陆用户访问,如signin页面""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import uuid | |
from PIL import Image | |
from flask.ext.uploads import extension | |
def random_filename(): | |
"""生成伪随机uuid字符串,用做文件名""" | |
return str(uuid.uuid4()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% macro show_ps(ps) %} | |
<!-- level 1 --> | |
<ul class="ps-lv1-list"> | |
{% for mt in ps %} | |
<li class="ps-lv1" data-id="{{ mt.MainTypeID }}"> | |
<span class="li-header li-header-right"></span><a href="{{ url_for('mtype', mtype_id=mt.MainTypeID) }}">{{ mt.Name }}</a> | |
<!-- level 2 --> | |
<ul class="ps-lv2-list"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// html code | |
<div class="products-wap clearfix"> | |
{% for product in products %} | |
<div class="product-item"> | |
<a href="{{ url_for('single_product', product_id=product.ProductID)}}"> | |
<img class="product-image" title="{{ product.Product }}" src="{{ product.ImageUrl }}"> | |
</a> | |
</div> | |
{% endfor %} | |
</div> |