Category : starlette

I’ve been studying this example project. Very concise and to the point, and a pleasant surprise, too: a Save File Dialog (a standard desktop File Dialog, opened from Chrome). The responsible code: src/html.py: @app.post(‘/download’) def form_post(request: Request, num: int = Form(…), multiply_by_2: bool = Form(False), action: str = Form(…)): if action == ‘convert’: result = ..

Read more

I have a following model where a parent can have many children. User can just create the parent or create a parent along with the child at the same time. class Parent(Base): name = Column(String) slug = Column(String) values = relationship(‘Child’, back_populates=’parent’) class Child(Base): name = Column(String, unique=True) slug = Column(String) parent_id = Column(Integer, ForeignKey(‘parent.id’)) ..

Read more

Assuming as request.url GET /fomantic-ui/default/semantic.min.css for certain file extension, e.g. .css, I need to serve a pre-compressed .gz version. From node-express I know an approach, that when applied to Starlette would be to simply manipulate the request.url.path and append a ‘.gz’ to it. However that results in an AttributeError: Can’t set attribute. What would be ..

Read more

I have a table of Attribute and AttributeValue. An attribute can have many values. This is how the design looks like between those table class Attribute(Base): id = Column(Integer, primary_key=True, index=True) title = Column(String(255), nullable=False) slug = Column(String, index=True, unique=True) value_required = Column(Boolean, default=False) attribute_values = relationship("AttributeValue", back_populates="attribute") attribute_products = relationship("AttributeProduct", back_populates="attribute") attributevariant = relationship("AttributeVariant", ..

Read more