D
--- no python application found, check your startup logs for errors ---Size: a a a
D
--- no python application found, check your startup logs for errors ---SM
--- no python application found, check your startup logs for errors ---app.register_blueprint лучше указывать без слэша в конце. там же вьюшка внутри / путь ждет, наверняка, а это уже второй получается/ и было понятно, что именно app не видно
[uwsgi]
http-socket = :8000
manage-script-name = True
mount = /=app:app
callable = app
SM
uwsgi ./socket-uwsgi.ini[uwsgi]
socket = 0.0.0.0:9000
protocol = uwsgi
wsgi-file = app.py
callable = app
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from .config import db_host, db_name, db_user, db_password
from .routes.list import list
from .routes.book import book
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = "mysql://{}:{}@{}/{}".format(db_user, db_password, db_host, db_name)
db = SQLAlchemy(app)
app.register_blueprint(list, url_prefix="/list/")
app.register_blueprint(book, url_prefix="/book/")
uwsgi --ini ./socket-uwsgi.ini
D
uwsgi --ini ./socket-uwsgi.ini
D
E
SM
S
-> % python
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> s = ""
>>> s[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: string index out of range
>>> s[:1]
''
>>> s[:1000]
''
SM
-> % python
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> s = ""
>>> s[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: string index out of range
>>> s[:1]
''
>>> s[:1000]
''
>>> s1 = '123'
>>> ss = ''
>>> ss[:1000]
''
>>> s1[:1000]
'123'
>>> ss[0:1000]
''
>>> ss[3:1000]
''
>>> s1[3:1000]
''
SM
-> % python
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> s = ""
>>> s[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: string index out of range
>>> s[:1]
''
>>> s[:1000]
''
S
>>> s1 = '123'
>>> ss = ''
>>> ss[:1000]
''
>>> s1[:1000]
'123'
>>> ss[0:1000]
''
>>> ss[3:1000]
''
>>> s1[3:1000]
''
S
DA
DA
SM
>>> a = [1,2,3]
>>> a[4:6]
[]
SM
KM
DI
[] в случае отсутствия элемента не возвращает None )SM
[] в случае отсутствия элемента не возвращает None )D
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from config import db_host, db_name, db_user, db_password
engine = create_engine("mysql://{}:{}@{}/{}".format(db_user, db_password, db_host, db_name), convert_unicode=True, echo=True)
db_session = scoped_session(sessionmaker(autocommit=False, autoflush=False, bind=engine))
Base = declarative_base()
Base.query = db_session.query_property()
def init_db():
# import all modules here that might define models so that
# they will be registered properly on the metadata. Otherwise
# you will have to import them first before calling init_db()
from models.book import Book
Base.metadata.create_all(bind=engine) # не работает
Book.__table__.create(bind=engine) # работает
if __name__ == "__main__":
init_db()
from sqlalchemy import Column, Integer, String
from database import Base
class Book(Base):
__tablename__ = "books"
id = Column(Integer, autoincrement=True, primary_key=True)
title = Column(String(80), nullable=False)
def __repr__(self):
return "<Title: {}>".format(self.title)