예제 #1
0
파일: main.py 프로젝트: Ivan0042/test_site
def add_listening():
    snd = Application().context.query(Sound).filter(
        Sound.id == request.get_json()["id"]).first()
    if f'{snd.id}viewed' not in session:
        listn = pickle.loads(snd.listening)
        listn.append(0)
        snd.listening = pickle.dumps(listn)
        session[f'{snd.id}viewed'] = 1
        Application().context.commit()
    return 'a'
예제 #2
0
class User(Application().model, UserMixin):
    __tablename__ = "users"

    id = Column(Integer, primary_key=True, autoincrement=True)
    name = Column(String, nullable=True)
    sename = Column(String, nullable=True)
    nickname = Column(String, nullable=True)
    birthday = Column(Date, nullable=True)
    icon = Column(String, nullable=True, default="img/lol.png")

    email = Column(String, index=True, unique=True, nullable=True)
    phone = Column(Integer, nullable=True)

    type = Column(Integer, default=1)

    hashed_password = Column(String, nullable=True)

    @property
    def password(self):
        return self.hashed_password

    @password.setter
    def password(self, val):
        self.hashed_password = generate_password_hash(val)

    def check_password(self, password):
        return check_password_hash(self.hashed_password, password)
예제 #3
0
class ListSound(Application().model):
    __tablename__ = "ListsSound"

    id = Column(Integer, primary_key=True)
    id_user = Column(Integer)
    name = Column(String, nullable=True)
    sounds = Column(LargeBinary, nullable=True, default=pickle.dumps(set()))
예제 #4
0
class Comment(Application().model):
    __tablename__ = "comments"

    id = Column(Integer, primary_key=True)
    text = Column(String, nullable=True)
    created_date = Column(DateTime, default=datetime.datetime.now)
    id_user = Column(Integer)
    id_sound = Column(Integer)
예제 #5
0
class Sound(Application().model):
    __tablename__ = "sounds"

    id = Column(Integer, primary_key=True)
    name = Column(String, nullable=True)
    img = Column(String, nullable=True)
    file_name = Column(String, nullable=True)
    teg = Column(String, nullable=True)
    listening = Column(LargeBinary, nullable=True, default=pickle.dumps([]))
    like = Column(LargeBinary, nullable=True, default=pickle.dumps([]))
    dislike = Column(LargeBinary, nullable=True, default=pickle.dumps([]))
    created_date = Column(DateTime, default=datetime.datetime.now)
    id_user = Column(Integer)
예제 #6
0
파일: main.py 프로젝트: Ivan0042/test_site
def load_user(user_id):
    db_sess = Application().context
    return db_sess.query(User).get(user_id)
예제 #7
0
파일: main.py 프로젝트: Ivan0042/test_site
def main():
    Application().create_context("db/sound.db")
    app.run()
예제 #8
0
파일: main.py 프로젝트: Ivan0042/test_site
from forms.ReqistrationForm import RegisterForm
from forms.UploadMusicForm import UploadMusicForm
from forms.ProfileForm import ProfileForm

from Models.User import User
from Models.Sound import Sound

import os
import pickle

from flask import Flask, render_template, redirect, request, abort, session, make_response, jsonify
from flask_login import login_user, logout_user, login_required
from sqlalchemy import desc
from forms.comment import Comment

Application().app = Flask(__name__)
app = Application().app

app.config["FILE_DIR"] = os.path.dirname(os.path.abspath(__file__))

login_manager = Application().login_manager
state = 'Новые треки'


@login_manager.user_loader
def load_user(user_id):
    db_sess = Application().context
    return db_sess.query(User).get(user_id)


@app.route("/", methods=['GET', 'POST'])