Flask

Using proper file structure with SQLAlchemy and how to add data to db

浪尽此生 提交于 2020-12-31 06:49:12
问题 I am trying to build a simple blogging platform to learn Python and Flask. I am using SQLAlchemy to connect to a Postgres db hosted on Heroku and flask_s3 to serve static files from an AWS bucket. Im mostly following along from this: https://gist.github.com/mayukh18/2223bc8fc152631205abd7cbf1efdd41/ All was going well, it is correctly hosted on Heroku and connceted to AWS S3 bucket, ready to go. I am stuck however on how to add blog posts to the database through some kind of form or route

Using proper file structure with SQLAlchemy and how to add data to db

老子叫甜甜 提交于 2020-12-31 06:48:30
问题 I am trying to build a simple blogging platform to learn Python and Flask. I am using SQLAlchemy to connect to a Postgres db hosted on Heroku and flask_s3 to serve static files from an AWS bucket. Im mostly following along from this: https://gist.github.com/mayukh18/2223bc8fc152631205abd7cbf1efdd41/ All was going well, it is correctly hosted on Heroku and connceted to AWS S3 bucket, ready to go. I am stuck however on how to add blog posts to the database through some kind of form or route

Using proper file structure with SQLAlchemy and how to add data to db

不打扰是莪最后的温柔 提交于 2020-12-31 06:46:26
问题 I am trying to build a simple blogging platform to learn Python and Flask. I am using SQLAlchemy to connect to a Postgres db hosted on Heroku and flask_s3 to serve static files from an AWS bucket. Im mostly following along from this: https://gist.github.com/mayukh18/2223bc8fc152631205abd7cbf1efdd41/ All was going well, it is correctly hosted on Heroku and connceted to AWS S3 bucket, ready to go. I am stuck however on how to add blog posts to the database through some kind of form or route

微信大改版!新功能被网友骂上热搜!

对着背影说爱祢 提交于 2020-12-31 00:09:08
点击上方“ Python进击者 ”,选择“ 星标 ”公众号 超级无敌干货推送给你!!! 微信版本更新又上热搜了! 深夜里阅读量就飙到了3.8亿,这是有大变动? ! 很多细心的朋友已经发现,自己的微信个人资料页多了一个“微信豆”选项,放在如此重要的位置,这微信豆到底是什么东东? 对于这个选项有些好奇的小伙伴,可以在微信首页——“我”,点击上面的头像昵称处,查看“个人信息”,会出现微信豆内容。 微信官方现在给出了微信豆的含义,微信豆是用于支付微信内虚拟物品的道具,目前支持在视频号中购买虚拟礼物。 想要获得微信豆,必须进行充值。iOS 充值的微信豆只能在 iOS 消费。 价格方面:7个1元、126个18元、350个50元、896个128元、2086个298元、3626个518元。 这个功能一经发现,网友们就炸开了锅,#微信推出微信豆#的词条也冲上了微博热搜。 有人认为,这违背了聊天软件的初衷,越来越花里胡哨: “聊天软件不好好做又开始上乱七八糟的东西了。” “聊天工具做的什么都有就离谱。” “一个聊天软件,越来越臃肿。” “过于饱和了,功能明显多到浪费。” “我只想用它和亲朋好友聊天视频,别的不想用。” 还有很多网友直指微信再这样下去要变成“第二个QQ”,微信豆让他们想起了Q币。 2002年5月,腾讯公司开发了虚拟货币系统,代表符号定名为“Q币”,通常它的兑价是1Q币=1人民币

where to keep js files in Flask applications?

牧云@^-^@ 提交于 2020-12-30 02:12:30
问题 I am new to flask and using it to serve index.html at "localhost:5000/". Currently I have only 3 files: index.html, angular.js, and app.js; and all of them are in same folder. I am serving index.html as : @app.route('/') def index(): return make_response(open('index.html').read()) I want to include angular.js and app.js in index.html. I tried this : <script src="angular.js"></script> <script src="app_controller.js"></script> But it is not including both the files (which I checked from 'view

where to keep js files in Flask applications?

孤街浪徒 提交于 2020-12-30 02:12:06
问题 I am new to flask and using it to serve index.html at "localhost:5000/". Currently I have only 3 files: index.html, angular.js, and app.js; and all of them are in same folder. I am serving index.html as : @app.route('/') def index(): return make_response(open('index.html').read()) I want to include angular.js and app.js in index.html. I tried this : <script src="angular.js"></script> <script src="app_controller.js"></script> But it is not including both the files (which I checked from 'view

where to keep js files in Flask applications?

心不动则不痛 提交于 2020-12-30 02:11:19
问题 I am new to flask and using it to serve index.html at "localhost:5000/". Currently I have only 3 files: index.html, angular.js, and app.js; and all of them are in same folder. I am serving index.html as : @app.route('/') def index(): return make_response(open('index.html').read()) I want to include angular.js and app.js in index.html. I tried this : <script src="angular.js"></script> <script src="app_controller.js"></script> But it is not including both the files (which I checked from 'view

Create selectfield options with custom attributes in WTForms

南楼画角 提交于 2020-12-29 12:23:56
问题 I am trying to create a SelectField or SelectMultipleField that allows me to add attributes to it's <option> tags. I am trying to add attributes like data-id or another data-____ . I have not been able to figure out how to do this as it only seems possible to add attributes to the <select> tag itself and not the options. The end result should be something like: <select id="regularstuff-here" name="regular-name-here"> <option value="1" data-id="somedata here" >Some Name here</option> <option

flask sqlalchemy many to many relationship with extra field

流过昼夜 提交于 2020-12-29 09:11:57
问题 I have 2 tables: restaurants and foods, and a 3rd table restaurants_foods which stores the many to many relationship between the 2 tables restaurants_foods = db.Table('restaurants_foods', db.Column('restaurant_id', db.Integer, db.ForeignKey('restaurants.id'), primary_key=True), db.Column('food_id', db.Integer, db.ForeignKey('foods.id'), primary_key=True), db.Column('food_price', db.Float) ) class Food(Model): __tablename__ = "foods" id = db.Column(db.Integer, primary_key=True, autoincrement

flask sqlalchemy many to many relationship with extra field

微笑、不失礼 提交于 2020-12-29 09:11:57
问题 I have 2 tables: restaurants and foods, and a 3rd table restaurants_foods which stores the many to many relationship between the 2 tables restaurants_foods = db.Table('restaurants_foods', db.Column('restaurant_id', db.Integer, db.ForeignKey('restaurants.id'), primary_key=True), db.Column('food_id', db.Integer, db.ForeignKey('foods.id'), primary_key=True), db.Column('food_price', db.Float) ) class Food(Model): __tablename__ = "foods" id = db.Column(db.Integer, primary_key=True, autoincrement