Flask

Flask app gives a “ 'NoneType' object has no attribute 'drivername' ” error

点点圈 提交于 2021-02-10 14:15:40
问题 I got a VPS and I wanted to host my flask app there. I followed DigitalOcean's tutorial on "How To Serve Flask Applications with Gunicorn and Nginx on Ubuntu 18.04" (I didnt get the VPS from DO) and everything worked fine with the example app... when I tried to replace the files with my app's files and host the app again I get a 500 error. The 500 error doesnt appear everywhere. It comes up where my .db file is envoled like where I have posts or users etc.. Everything else loads up fine. The

How to implement external auth in KONG?

微笑、不失礼 提交于 2021-02-10 14:14:46
问题 I'm using KONG API Gateway, and I want to implement JWT authentication as separate microservice (not using KONG plugin), now I can easily register this service with KONG, and so users can register and login. Assume an authenticated user had sent a request with a token attached in the header, how to make KONG forwards the request to the authentication service first, then if it is valid the request is forwarded to the requested service? 回答1: Yes you can (But I have not used them) there is as

Considering URL redirections: How to use GUIs of web applications running in different containers within the same docker network on a remote server?

青春壹個敷衍的年華 提交于 2021-02-10 12:44:55
问题 I have the feeling that I am overlooking something obvious as my solutions/ideas so far seem too cumbersome. I have searched intensively for a good solution, but so far without success - probably because I do not know what to look for. Question: How do you interact with the graphical interfaces of web servers running in different containers (within the same Docker Network) on a remote server, given URL redirections between these containers? Initial situation: I have two containers (a Flask

Considering URL redirections: How to use GUIs of web applications running in different containers within the same docker network on a remote server?

淺唱寂寞╮ 提交于 2021-02-10 12:43:00
问题 I have the feeling that I am overlooking something obvious as my solutions/ideas so far seem too cumbersome. I have searched intensively for a good solution, but so far without success - probably because I do not know what to look for. Question: How do you interact with the graphical interfaces of web servers running in different containers (within the same Docker Network) on a remote server, given URL redirections between these containers? Initial situation: I have two containers (a Flask

Flask-migrate: change model attributes and rename corresponding database columns

折月煮酒 提交于 2021-02-10 12:38:07
问题 I have a bit of experience with Flask but not very much with databases (Flask-migrate / alembic / SqlAlchemy). I'm following this tutorial and things are working quite alright. I have a User model like this: # user_model.py from app import DB ... other imports class User(UserMixin, DB.Model): __tablename__ = 'users' id = DB.Column(DB.Integer, primary_key=True) username = DB.Column(DB.String(64), index=True, unique=True) email = DB.Column(DB.String(120), index=True, unique=True) password_hash

Flask-migrate: change model attributes and rename corresponding database columns

给你一囗甜甜゛ 提交于 2021-02-10 12:37:06
问题 I have a bit of experience with Flask but not very much with databases (Flask-migrate / alembic / SqlAlchemy). I'm following this tutorial and things are working quite alright. I have a User model like this: # user_model.py from app import DB ... other imports class User(UserMixin, DB.Model): __tablename__ = 'users' id = DB.Column(DB.Integer, primary_key=True) username = DB.Column(DB.String(64), index=True, unique=True) email = DB.Column(DB.String(120), index=True, unique=True) password_hash

Installing setuptools from source “No module named numbers” error

天大地大妈咪最大 提交于 2021-02-10 12:35:40
问题 This is based on Install Python Flask without using pip My environment has no rpms installed or enabled, nor do I have pip, easy_install, virtualenv, etc. Based on the answer in the linked question, I need to install setuptools in order to install Jinja. To do this, I downloaded and un-tared setuptools-19.1.1.tar.gz. I then run the following command and get an ImportError: $python setup.py install Traceback (most recent call last): File "setup.py", line 21, in <module> exec(init_file.read(),

Installing setuptools from source “No module named numbers” error

时光怂恿深爱的人放手 提交于 2021-02-10 12:35:27
问题 This is based on Install Python Flask without using pip My environment has no rpms installed or enabled, nor do I have pip, easy_install, virtualenv, etc. Based on the answer in the linked question, I need to install setuptools in order to install Jinja. To do this, I downloaded and un-tared setuptools-19.1.1.tar.gz. I then run the following command and get an ImportError: $python setup.py install Traceback (most recent call last): File "setup.py", line 21, in <module> exec(init_file.read(),

Populating dropdown dynamically from list with Jinja

天大地大妈咪最大 提交于 2021-02-10 12:23:26
问题 I have a Flask application which, from one of its routes, produces a list of data that I would then like to display in a dropdown menu on the front-end. The issue is, a different number of items will exist in each list that will populate the same dropdown menu. For example, one users accounts might have three items, while another's might have twenty. My route looks like: @app.route("/test", methods=['GET', 'POST']) def test(): #list with 10 items is generated here return render_template('test

flask消息闪现

故事扮演 提交于 2021-02-10 09:34:02
反馈,是良好的应用和用户界面的重要构成。如果用户得不到足够的反馈,他们很可能开始厌恶这个应用。 Flask 提供了消息闪现系统,可以简单地给用户反馈。 消息闪现系统通常会在请求结束时记录信息,并在下一个(且仅在下一个)请求中访问记录的信息。展现这些消息通常结合要模板布局。 使用 flash() 方法可以闪现一条消息。 要操作消息本身,请使用 get_flashed_messages() 函数,并且在模板中也可以使用。 简单的闪现 这里是一个完成的例子: from flask import Flask , flash , redirect , render_template , \ request , url_for app = Flask ( __name__ ) app . secret_key = 'some_secret' @app.route ( '/' ) def index (): return render_template ( 'index.html' ) @app.route ( '/login' , methods = [ 'GET' , 'POST' ]) def login (): error = None if request . method == 'POST' : if request . form [ 'username' ] != 'admin'