示例#1
0
 def _():
     newPost = Post(store=self.store,
                    author=user.decode('utf-8'), 
                    title=title.decode('utf-8'), 
                    url=url.decode('utf-8'), 
                    content=desc.decode('utf-8'))
     return newPost
示例#2
0
def post_add():
    if request.method=='POST':
        new_post = Post(id=app.current_id, photo_url=request.form['photo_url'],
                        name=request.form['name'],
                        body=request.form['body'])
        post_store.add(new_post)
        app.current_id += 1
        return redirect(url_for('home'))
    elif request.method=='GET':
        return render_template('post-add.html')
示例#3
0
def post_add():
    if request.method == "POST":
        new_post = Post(id=app.current_id,
                        photo_url=request.form["photo_url"],
                        name=request.form["name"],
                        body=request.form["body"])
        app.current_id += 1
        post_store.add(new_post)
        return redirect(url_for("home"))
    elif request.method == "GET":
        return render_template('post-add.html')
示例#4
0
from flask import Flask, render_template, request, redirect, url_for
from store import Post, PostStore


app = Flask(__name__)

dummy_posts = [
    Post(id=1,
         photo_url='https://images.pexels.com/photos/415829/pexels-photo-415829.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=50&w=50',
         name='Sara',
         body='Lorem Ipsum'),
    Post(id=2,
         photo_url='https://images.pexels.com/photos/736716/pexels-photo-736716.jpeg?auto=compress&cs=tinysrgb&dpr=1&h=100&w=100',
         name='John',
         body='Lorem Ipsum'),
]
post_store = PostStore()
post_store.add(dummy_posts[0])
post_store.add(dummy_posts[1])

app.current_id = 3
posts = post_store.get_all()

@app.route('/')
@app.route('/index')
def home():
    return render_template('index.html', posts = post_store.get_all())

@app.route('/posts/add', methods=['GET', 'POST'])
def post_add():
    if request.method == 'POST':
示例#5
0
文件: main.py 项目: fatenali12/Posty
from flask import Flask, render_template, request, redirect, url_for
from store import Post, PostStore
app = Flask(__name__)

dummy_posts = [
    Post(
        id=1,
        photo_url=
        "https://images.pexels.com/photos/324658/pexels-photo-324658.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500",
        name="Faten Ali",
        body=
        "Lorem ipsum, dolor sit amet consectetur adipisicing elit Sit fugit distinctio quisquam quia aliquam itaque ipsa!Ab corporis reiciendis tenetur nemo, ipsa odio hic veritatis nam, quaerat expedita vel esse."
    ),
    Post(
        id=2,
        photo_url=
        "https://images.pexels.com/photos/936229/pexels-photo-936229.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500",
        name="Ahmed Ali",
        body=
        "Lorem ipsum, dolor sit amet consectetur adipisicing elit. Sit fugit distinctio quisquam quia aliquam itaque ipsa!Ab corporis reiciendis tenetur nemo, ipsa odio hic veritatis nam, quaerat expedita vel esse."
    )
]
post_store = PostStore()
post_store.add(dummy_posts[0])
post_store.add(dummy_posts[1])

app.current_id = 3


@app.route('/')
def home():
示例#6
0
from flask import Flask, render_template, request, redirect, url_for
from store import PostStore, Post

app = Flask(__name__)

dummy_posts = [
    Post(
        id=1,
        photo_url='https://avatars1.githubusercontent.com/u/24706903?s=460&v=4',
        name='Adel Lassag',
        body='Hello Coretabs!'),
    Post(
        id=2,
        photo_url=
        'https://images.pexels.com/photos/736716/pexels-photo-736716.jpeg?auto=compress&cs=tinysrgb&dpr=1&h=100&w=100',
        name='John',
        body='Ut enim ad minim veniam.'),
]
post_store = PostStore([])
post_store.add(dummy_posts[0])
post_store.add(dummy_posts[1])

app.current_id = 3


@app.route('/')
def home():
    return render_template('index.html', posts=post_store.get_all())


@app.route('/posts/add', methods=["GET", "POST"])
示例#7
0
from flask import Flask, render_template, request, redirect, url_for
from store import PostStore, Post

app = Flask(__name__)

dummy_posts = [
    Post(
        id=1,
        photo_url=
        'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxISEhUSEhIVFRUVGBUVGBcXGBUYFRUYFRYXFxUVFxUYHSggGBolGxYVITEhJSkrLi4uFx8zODMtNygtLisBCgoKDg0OGhAQFy0dHx0tLS0tLSstLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tKy0tLTcrLSs3LSstK//AABEIAOEA4QMBIgACEQEDEQH/xAAcAAABBQEBAQAAAAAAAAAAAAAFAAIDBAYBBwj/x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us896GrQfwdDKxjPugA+QVirV2G2vcuMsomNkeJkrWtIQKiJVqlTnZNps7RHJWKtQMH5urIMrVQyw1VKtjI8eS5WpOiSbuOiZ9U2Fz+dULf8FqiL6077o9V1Wf5Nckh+xdoB1lQralJJYpj4nGKVJJRFhXhSLVNEklqj+REuwXXVUrqSVINFTiGg8D8locD+tp+NP4hJJAvYT6R71U1KxPSn9d/dHxKSS56HGap/rmePyK3Ow8F1JZPJ/Rpw/kpcS/VuXkGI/WP8Ukk7wP8jK8j8EzNlZppJLuQOayQqvWSSRspA2r7S7gP1oSSSP9kM9B8pYfbzSSWsQS4b23Ltf22JJKykNxXts80/De0VxJUWEEkkkRR//Z',
        name='Awwab',
        body='My first post'),
    Post(
        id=2,
        photo_url=
        'https://images.pexels.com/photos/736716/pexels-photo-736716.jpeg?auto=compress&cs=tinysrgb&dpr=1&h=100&w=100',
        name='John',
        body='Lorem Ipsum'),
]
post_store = PostStore()
post_store.add(dummy_posts[0])
post_store.add(dummy_posts[1])
app.current_id = 3


@app.route('/')
@app.route('/index')
def home():
    return render_template('index.html', posts=post_store.get_all())

示例#8
0
from flask import Flask, render_template, request, url_for, redirect
from store import Post, PostStore

app = Flask(__name__)

dummy_posts = [
    Post(
        id=1,
        photo_url=
        'https://images.pexels.com/photos/415829/pexels-photo-415829.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=50&w=50',
        name='Sara',
        body=
        'Lorem ipsum dolor sit amet consectetur adipisicing elit. Inventore repellendus itaque rem vitae,\
                    reprehenderit tempora officia sapiente? Hic, quae qui atque, quaerat, vitae distinctio libero quas\
                    similique facilis iste nostrum?'),
    Post(
        id=2,
        photo_url=
        'https://images.pexels.com/photos/736716/pexels-photo-736716.jpeg?auto=compress&cs=tinysrgb&dpr=1&h=100&w=100',
        name='John',
        body=
        'Quae qui atque, quaerat, vitae distinctio libero quas similique facilis iste nostrum?'
    ),
]
post_store = PostStore()
post_store.add(dummy_posts[0])
post_store.add(dummy_posts[1])

posts = post_store.get_all()