Flask

What is the form of my local postgresql database url?

二次信任 提交于 2020-08-27 03:30:40
问题 I am going through a flask/sqlalchemy tutorial https://pythonhosted.org/Flask-SQLAlchemy/quickstart.html#a-minimal-application and I configured my database url to be: postgres://username:password@localhost:5432/dbname when I run db.create_all() in the interactive python shell it doesn't throw any errors, but it doesn't do anything either. From what I understand it is supposed to create the User table with three columns; id, username, and email . from flask import Flask, url_for, render

Connecting to localhost using Python-flask on Google Colab?

[亡魂溺海] 提交于 2020-08-26 07:54:28
问题 I am a newcomer to flask. I cannot access localhost:5000 or 127.0.0.1:5000 . I am using flask . I have tried many solutions but none of them worked for me. Here's the code from flask import Flask app = Flask(__name__) @app.route('/') def hello_world(): return ('Hello World') if __name__ == '__main__': app.run() I get this * Serving Flask app "__main__" (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production

How can I create repetitive form elements in a DRY way with Flask-WTForms?

怎甘沉沦 提交于 2020-08-25 04:56:06
问题 I have a WTForms form where I want the user to be able to upload up to 10 images, and also give the images captions and credits. Currently I declare all 10 sets of fields, but this seems redundant. Is there a way to create form fields with dynamic names, so I could create them in a loop? class MyForm(Form): image1 = FileField('Upload') image1_caption = StringField('Caption') image1_credit = StringField('Credit') image2 = FileField('Upload') image2_caption = StringField('Caption') image2

flask_uploads: ImportError: cannot import name 'secure_filename'

妖精的绣舞 提交于 2020-08-24 10:21:34
问题 I want to create a form that allows to send a picture with a description using flask forms. I tried to use this video: https://www.youtube.com/watch?v=Exf8RbgKmhM but I had troubles when launching app.py: ➜ website git:(master) ✗ python3.6 app.py Traceback (most recent call last): File "app.py", line 10, in <module> from flask.ext.uploads import UploadSet, configure_uploads, IMAGES ModuleNotFoundError: No module named 'flask.ext' I had to replace flask.ext.uploads by flask_uploads but now I

flask_uploads: ImportError: cannot import name 'secure_filename'

落花浮王杯 提交于 2020-08-24 10:19:52
问题 I want to create a form that allows to send a picture with a description using flask forms. I tried to use this video: https://www.youtube.com/watch?v=Exf8RbgKmhM but I had troubles when launching app.py: ➜ website git:(master) ✗ python3.6 app.py Traceback (most recent call last): File "app.py", line 10, in <module> from flask.ext.uploads import UploadSet, configure_uploads, IMAGES ModuleNotFoundError: No module named 'flask.ext' I had to replace flask.ext.uploads by flask_uploads but now I

flask_uploads: ImportError: cannot import name 'secure_filename'

末鹿安然 提交于 2020-08-24 10:18:34
问题 I want to create a form that allows to send a picture with a description using flask forms. I tried to use this video: https://www.youtube.com/watch?v=Exf8RbgKmhM but I had troubles when launching app.py: ➜ website git:(master) ✗ python3.6 app.py Traceback (most recent call last): File "app.py", line 10, in <module> from flask.ext.uploads import UploadSet, configure_uploads, IMAGES ModuleNotFoundError: No module named 'flask.ext' I had to replace flask.ext.uploads by flask_uploads but now I

Use database to store session instead of Cookie with Flask

南楼画角 提交于 2020-08-24 04:27:07
问题 I have a python project with Flask. I'm using SQL Alchemy (according to this page of the documentation : http://flask.pocoo.org/docs/0.10/patterns/sqlalche) to handle my database actions. I'm using Flask.session to store user's information (authentication status, preferences, ...) Default Flask's Session behaviour is to store sessions in user's cookie, and to sign this cookie with secret_key so users can't alter it, but they can read it. I don't like that my users are able to "see" session's

Use database to store session instead of Cookie with Flask

↘锁芯ラ 提交于 2020-08-24 04:26:58
问题 I have a python project with Flask. I'm using SQL Alchemy (according to this page of the documentation : http://flask.pocoo.org/docs/0.10/patterns/sqlalche) to handle my database actions. I'm using Flask.session to store user's information (authentication status, preferences, ...) Default Flask's Session behaviour is to store sessions in user's cookie, and to sign this cookie with secret_key so users can't alter it, but they can read it. I don't like that my users are able to "see" session's

Flask-Bootstrap custom theme

梦想与她 提交于 2020-08-23 07:48:39
问题 I made a flask app with flask-bootstrap. I am using virtualenv as well. Where would I find the stylesheet that I edit to customize the colors? Or is there another way to have custom colors? 回答1: Add you custom colors to a css file, e.g. mystyle.css , put it under the static folder, then add your custom css file to your template. {% block styles %} {{super()}} <link rel="stylesheet" href="{{url_for('.static', filename='mystyle.css')}}"> {% endblock %} Check the documentation here: Adding a

Flask-Bootstrap custom theme

谁说胖子不能爱 提交于 2020-08-23 07:48:07
问题 I made a flask app with flask-bootstrap. I am using virtualenv as well. Where would I find the stylesheet that I edit to customize the colors? Or is there another way to have custom colors? 回答1: Add you custom colors to a css file, e.g. mystyle.css , put it under the static folder, then add your custom css file to your template. {% block styles %} {{super()}} <link rel="stylesheet" href="{{url_for('.static', filename='mystyle.css')}}"> {% endblock %} Check the documentation here: Adding a