From coreybrett at gmail.com Thu Nov 7 19:54:46 2019 From: coreybrett at gmail.com (Corey Boyle) Date: Thu, 7 Nov 2019 19:54:46 -0500 Subject: [Flask] Add current_user to exceptions emails Message-ID: Anyone know how to add the value of current_user to emails generated by exceptions? -------------- next part -------------- An HTML attachment was scrubbed... URL: From nitin1.jain at altran.com Fri Nov 8 21:42:14 2019 From: nitin1.jain at altran.com (Nitin Jain) Date: Sat, 9 Nov 2019 02:42:14 +0000 Subject: [Flask] [flask-sqlalchemy] lazy = True Option Message-ID: Hi all I am using Flask / flask-sqlalchemy and postgres DB for web application and currently facing issues w.r.t performance i.e. high cpu / memory / response time. We have many tables with one to many relationships . I have below queries :- 1. In terms of performance what is the difference between lazy = True or lazy = dynamic option. 2. As of now at table mapping level , loader options are defined . Is there any reference on how to define at query level . Will it help to improve the performance ? 3. If we have many level of nesting (parent - child relationships ) , is it possible to exclude certain relationships selectively ? 4. For search feature , can we setup index parameter for frequently used columns. If yes , any reference ? Regards Nitin ===================================================== Please refer to https://northamerica.altran.com/email-disclaimer for important disclosures regarding this electronic communication. ===================================================== -------------- next part -------------- An HTML attachment was scrubbed... URL: From flaskee at protonmail.com Tue Nov 12 10:14:03 2019 From: flaskee at protonmail.com (flaskee) Date: Tue, 12 Nov 2019 15:14:03 +0000 Subject: [Flask] intermittent Internal Server Error on running flask site Message-ID: Hello all: I'm just looking for pointers on where to check, in order to track this down. The problem: I have a production flask site, on Apache /2.4.38; Debian 10.1, using a virtualized Python3.5/HTML5 site. It works well! except that every few days it crashes with an Internal Server Error - 500. When "crashed", the site itself is still loaded in Apache2, as nmap -A nmap -sP nmap -A nmap -sP all report the host is loaded; and other static sites running on the same apache server still serve up just fine. It does not *appear* to be a coding error, as when it is running, I have negotiated to each and every page in the site, without causing a crash. Still, randomly, the site fails. I have been through: * the web sites' error.log * the web sites' acess.log * /var/log/apache2/error.log * /var/log/apache2/error.log.1 * /var/log/syslog and I'm not finding the cause. A sudo systemctl stop apache2.service sudo systemctl start apache2.service gets the site running again. Any tips on where else to check? Thank you! The Error Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator at webmaster at mydomain.org to inform them of the time this error occurred, and the actions you performed just before this error. More information about this error may be available in the server error log. Sent with [ProtonMail](https://protonmail.com) Secure Email. -------------- next part -------------- An HTML attachment was scrubbed... URL: From flaskee at protonmail.com Tue Nov 12 15:20:08 2019 From: flaskee at protonmail.com (flaskee) Date: Tue, 12 Nov 2019 20:20:08 +0000 Subject: [Flask] Other flask interactive resources Message-ID: <3x9ZUTKR6HVAtvLaNa9D5KXty9oYfi6KzSeRbgywCi7EdTfkqWsTQWDC1vKuo_nV-hDQ2cipyC-fwqsJ1quQUk4gdr5FgJ53KEp-qo41okU=@protonmail.com> Is there a list of other flask-related interactive(ish) resources to help with questions? Other mailing lists? etc? I know there is a flask chat out there, but searches aren't finding it for me. Thank you -------------- next part -------------- An HTML attachment was scrubbed... URL: From linux4ms at gmail.com Wed Nov 13 11:09:57 2019 From: linux4ms at gmail.com (Ben Duncan) Date: Wed, 13 Nov 2019 10:09:57 -0600 Subject: [Flask] Getting 'The CSRF session token is missing.' Message-ID: Can someone tell me what I'm doing wrong ? I'm trying to build the app in blueprint style, everything seems to work except csrf session stuff .... As usual, thanks ... The MASTER __init__.py ---------------------------------------------------------------------------------------------------- import sys from flask import Flask from flask import session from flask import g from flask_sqlalchemy import SQLAlchemy from flask_session import Session # CSRF Protection .... from flask_wtf.csrf import CSRFProtect from flask_wtf.csrf import CSRFError # Globally accessible libraries pgdb = SQLAlchemy() from sqlalchemy import MetaData from flask_sqlalchemy import SQLAlchemy metadata = MetaData() def create_app(): """Initialize the core application.""" app = Flask(__name__) app.config.from_pyfile('config.cfg') #session.init_app(app) Session(app) # initialize Flask extensions #pgdb = SQLAlchemy() pgdb.app = app pgdb.init_app(app) pgdb.Model.metadata.reflect(pgdb.engine) class office_table(pgdb.Model): __table__ = pgdb.Model.metadata.tables['office'] # Initialize Blueprints with app.app_context(): # Include our Routes #from . import routes # Register Blueprints #from .views.profile import profile #app.register_blueprint(profile) # Method 1 - import the home.py file from views # tghen register it as home.home from .views.home import home app.register_blueprint( home ) return app ---------------------------------------------------------------------------------------------------------------- The config file: import os from datetime import timedelta #SECRET_KEY = os.urandom(64) SECRET_KEY = 'Mars Random Key Stuff' #SERVER_NAME = 'su-postgres-ben-3.mec.ms.gov:5000' SERVER_NAME = '10.13.70.47:5000' # Session management SESSION_TYPE = 'filesystem' SESSION_FILE_DIR = 'flask_session' SESSION_COOKIE_PATH = '/' SESSION_KEY_PREFIX = 'flsk' PERMANENT_SESSION_LIFETIME = timedelta(minutes=15) # Per user config: # app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(minutes=15) SQLALCHEMY_DATABASE_URI = 'postgres:// flask:flask at 10.13.70.47:7103/ac03303_live' SQLALCHEMY_TRACK_MODIFICATIONS = False SQLALCHEMY_POOL_SIZE = 10 SQLALCHEMY_ECHO = False # Debugging testing DEBUG = True DEVELOPMENT = True TESTING = True TEMPLATES_AUTO_RELOAD = True # SERVER_NAME = '' # YOUR defined variables go here APPLICATION = 'MECS APPLICATION' AUTHOR = 'Ben Duncan' -------------------------------------------------------------------------------------------------- The run.sh and wsgi.py program: #!/usr/bin/env python # # -*- coding: utf-8 -*- # SAMPLE TO SHOW FLASK_SQLALCHEMY # AND HOW TO USE IT !!! # import os, sys, string, copy, time import getopt, cdecimal from types import * from datetime import date sys.modules['decimal'] = cdecimal # Base wsgi application starter #from flask import g, session from mars import create_app app = create_app() app.config['SOMETHING'] = 'wsgi.py' # csrf error # See : https://flask-wtf.readthedocs.io/en/stable/csrf.html#csrf # @app.errorhandler(CSRFError) # def handle_csrf_error(e): # return render_template('csrf_error.html', reason=e.description), 400 if __name__ == "__main__": app.run() Run.sh #!/bin/sh #rm -rf flask_session/* export FLASK_APP=wsgi.py export FLASK_ENV=development flask run --host=0.0.0.0 --cert=adhoc --------------------------------------------------------------------------------------------------------------------------------------------------------- And finally the blueprinted app: #!/usr/bin/env python # # -*- coding: utf-8 -*- # SAMPLE TO SHOW FLASK_SQLALCHEMY # AND HOW TO USE IT !!! # import os, sys, string, copy, time import getopt, cdecimal from types import * from datetime import date sys.modules['decimal'] = cdecimal from pbkdf2 import * import binascii from struct import * import base64 import zlib import hashlib import binascii import hmac from hashlib import md5, sha1, sha224, sha256, sha384, sha512 TodaysDate = str(date.today()) from flask import Flask, render_template, request, redirect, url_for from flask import flash, make_response, escape, g from flask import Blueprint from flask import session home = Blueprint('home', __name__) # mars/views/home # Flask Specific from flask import current_app as app from flask import render_template, flash, redirect, url_for, request, g, \ jsonify, current_app from flask import get_flashed_messages from flask.templating import Environment # Flask_wtf from: https://flask-wtf.readthedocs.io/en/stable/ from flask_wtf import FlaskForm # Wtforms: https://wtforms.readthedocs.io/en/stable/ from wtforms import Form, BooleanField, StringField, PasswordField, validators from wtforms import TextField, TextAreaField, SubmitField, RadioField, SelectField from wtforms import DecimalField, BooleanField, IntegerField, FloatField from wtforms import DateField, DateTimeField from wtforms.validators import * from wtforms.widgets import TextArea from mars import pgdb class office_table(pgdb.Model): __table__ = pgdb.Model.metadata.tables['office'] class fund_table(pgdb.Model): __table__ = pgdb.Model.metadata.tables['fund_type'] class user_table(pgdb.Model): __table__ = pgdb.Model.metadata.tables['users'] # Login Routine class LoginForm(FlaskForm): userid = StringField("userid", validators=[DataRequired()]) user_password = StringField("password: ", validators=[DataRequired()]) @home.route('/') @home.route('/login', methods=['GET', 'POST']) def login() : form = LoginForm() # Sessions ALWAYS considered new in login ... session.clear() ........................................... And the Template: .... (usual top of form stuff)
{{ form.csrf_token }}
Enter your User ID
.... and rest of stuff *Ben Duncan* DBA / Chief Software Architect Mississippi State Supreme Court Electronic Filing Division -------------- next part -------------- An HTML attachment was scrubbed... URL: From linux4ms at gmail.com Wed Nov 13 11:41:11 2019 From: linux4ms at gmail.com (Ben Duncan) Date: Wed, 13 Nov 2019 10:41:11 -0600 Subject: [Flask] Getting 'The CSRF session token is missing.' Message-ID: Argh .... stupid me, stupid me, stupid me: DONT USE the session.clear(), wipes way all stuff ... *Ben Duncan* DBA / Chief Software Architect Mississippi State Supreme Court Electronic Filing Division -------------- next part -------------- An HTML attachment was scrubbed... URL: From flaskee at protonmail.com Wed Nov 13 12:49:53 2019 From: flaskee at protonmail.com (flaskee) Date: Wed, 13 Nov 2019 17:49:53 +0000 Subject: [Flask] Fw: Re: Other flask interactive resources In-Reply-To: References: <3x9ZUTKR6HVAtvLaNa9D5KXty9oYfi6KzSeRbgywCi7EdTfkqWsTQWDC1vKuo_nV-hDQ2cipyC-fwqsJ1quQUk4gdr5FgJ53KEp-qo41okU=@protonmail.com> Message-ID: <6VAa6mTuT0Rzl_e2V50y4JW2SSpcBO5UP1tYuFyDTJNeEyFDJZHssj6C_iYe_xumYFxExjQFc7jteuyAWEqIRHb9Kt4M_rX0S5G9D2BA9gg=@protonmail.com> ??????? Original Message ??????? On Tuesday, November 12, 2019 3:52 PM, Carlos Azuaje wrote: > https://spectrum.chat/flask?tab=posts Thank you. You have to have a github id to sign up there? Yes? --nukedGithubwhenMicrosoftConsumedIt > El mar., 12 nov. 2019 a las 17:29, flaskee via Flask () escribi?: > >> Is there a list of other flask-related interactive(ish) resources >> to help with questions? >> >> Other mailing lists? etc? >> >> I know there is a flask chat out there, but searches aren't finding it for me. >> >> Thank you >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask > > -- > [Carlos Zambrano](https://www.linkedin.com/in/carlos-azuaje-559a33125/) - [Software Developer ](https://github.com/CharlyJazz) -------------- next part -------------- An HTML attachment was scrubbed... URL: From linux4ms at gmail.com Wed Nov 13 14:17:11 2019 From: linux4ms at gmail.com (Ben Duncan) Date: Wed, 13 Nov 2019 13:17:11 -0600 Subject: [Flask] Report Writer Message-ID: Any suggestion on a Report Write / PDF creator for Flask ? Thanks ... *Ben Duncan* DBA / Chief Software Architect Mississippi State Supreme Court Electronic Filing Division -------------- next part -------------- An HTML attachment was scrubbed... URL: From badrihippo at gmail.com Wed Nov 13 15:03:13 2019 From: badrihippo at gmail.com (Badri) Date: Thu, 14 Nov 2019 01:33:13 +0530 Subject: [Flask] Report Writer In-Reply-To: References: Message-ID: <1573675393.3.1@gmail.com> Are you familiar with LaTeX? If so, you could use use normal Jinja2 templates for .tex files, and generate pdfs from those resulting files. Are you planning to generate these reports live (ie. when users load the page on your site) or only locally (eg. having a local Python script that analyses your Flask and outputs the report to a PDF file)? ?Badri On Wed, Nov 13, 2019 at 13:17, Ben Duncan wrote: > Any suggestion on a Report Write / PDF creator for Flask ? > > Thanks ... > > *Ben Duncan* > DBA / Chief Software Architect > Mississippi State Supreme Court > Electronic Filing Division -------------- next part -------------- An HTML attachment was scrubbed... URL: From flaskee at protonmail.com Wed Nov 13 16:00:32 2019 From: flaskee at protonmail.com (flaskee) Date: Wed, 13 Nov 2019 21:00:32 +0000 Subject: [Flask] Report Writer -- pdf creation Message-ID: ??????? Original Message ??????? On Wednesday, November 13, 2019 2:17 PM, Ben Duncan wrote: > Any suggestion on a Report Write / PDF creator for Flask ? # "weasyprint" import weasyprint pdf = weasyprint.HTML('http://somesite/index.html').write_pdf() with open('somesite.pdf', mode="wb+") as filehandle: filehandle.write(pdf) # It works decently. -------------- next part -------------- An HTML attachment was scrubbed... URL: From flaskee at protonmail.com Wed Nov 13 16:02:28 2019 From: flaskee at protonmail.com (flaskee) Date: Wed, 13 Nov 2019 21:02:28 +0000 Subject: [Flask] intermittent Internal Server Error on running flask site In-Reply-To: References: Message-ID: Any tips on this one folks? (I am stuck) ??????? Original Message ??????? On Tuesday, November 12, 2019 10:14 AM, flaskee wrote: > Hello all: > > I'm just looking for pointers on where to check, in order to track this down. > > The problem: > > I have a production flask site, > on Apache /2.4.38; Debian 10.1, using a virtualized Python3.5/HTML5 site. > > It works well! except that every few days it crashes with an Internal Server Error - 500. > > When "crashed", the site itself is still loaded in Apache2, > as > nmap -A > nmap -sP > nmap -A > nmap -sP > all report the host is loaded; > and other static sites running on the same apache server still serve up just fine. > > It does not *appear* to be a coding error, > as when it is running, > I have negotiated to each and every page in the site, > without causing a crash. > > Still, randomly, the site fails. > > I have been through: > * the web sites' error.log > * the web sites' acess.log > * /var/log/apache2/error.log > * /var/log/apache2/error.log.1 > * /var/log/syslog > and I'm not finding the cause. > > A > sudo systemctl stop apache2.service > sudo systemctl start apache2.service > gets the site running again. > > Any tips on where else to check? > > Thank you! > > The Error > Internal Server Error > The server encountered an internal error or misconfiguration and was unable to complete your request. > > Please contact the server administrator at webmaster at mydomain.org to inform them of the time this error occurred, and the actions you performed just before this error. > > More information about this error may be available in the server error log. > > Sent with [ProtonMail](https://protonmail.com) Secure Email. -------------- next part -------------- An HTML attachment was scrubbed... URL: From paradox2005 at gmail.com Wed Nov 13 16:11:41 2019 From: paradox2005 at gmail.com (Adil Hasan) Date: Wed, 13 Nov 2019 21:11:41 +0000 Subject: [Flask] intermittent Internal Server Error on running flask site In-Reply-To: References: Message-ID: <20191113211140.GD4922@parsnip> Hello, I wonder. If you know rougly when it happens perhaps there's some info in the access log to indicate what the request was at that time? It could be that there's some request coming in that perhaps your code is not able to handle and causes the 500 error? hth adil On Wed, Nov 13, 2019 at 09:02:28PM +0000, flaskee via Flask wrote: > Any tips on this one folks? > (I am stuck) > > ??????? Original Message ??????? > On Tuesday, November 12, 2019 10:14 AM, flaskee wrote: > > > Hello all: > > > > I'm just looking for pointers on where to check, in order to track this down. > > > > The problem: > > > > I have a production flask site, > > on Apache /2.4.38; Debian 10.1, using a virtualized Python3.5/HTML5 site. > > > > It works well! except that every few days it crashes with an Internal Server Error - 500. > > > > When "crashed", the site itself is still loaded in Apache2, > > as > > nmap -A > > nmap -sP > > nmap -A > > nmap -sP > > all report the host is loaded; > > and other static sites running on the same apache server still serve up just fine. > > > > It does not *appear* to be a coding error, > > as when it is running, > > I have negotiated to each and every page in the site, > > without causing a crash. > > > > Still, randomly, the site fails. > > > > I have been through: > > * the web sites' error.log > > * the web sites' acess.log > > * /var/log/apache2/error.log > > * /var/log/apache2/error.log.1 > > * /var/log/syslog > > and I'm not finding the cause. > > > > A > > sudo systemctl stop apache2.service > > sudo systemctl start apache2.service > > gets the site running again. > > > > Any tips on where else to check? > > > > Thank you! > > > > The Error > > Internal Server Error > > The server encountered an internal error or misconfiguration and was unable to complete your request. > > > > Please contact the server administrator at webmaster at mydomain.org to inform them of the time this error occurred, and the actions you performed just before this error. > > > > More information about this error may be available in the server error log. > > > > Sent with [ProtonMail](https://protonmail.com) Secure Email. > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask From unai at sysbible.org Wed Nov 13 16:12:28 2019 From: unai at sysbible.org (Unai Rodriguez) Date: Wed, 13 Nov 2019 22:12:28 +0100 Subject: [Flask] intermittent Internal Server Error on running flask site In-Reply-To: References: Message-ID: <974a6f28-058a-4a91-99fc-b79254ecc6ab@www.fastmail.com> Yes you need to provide the actual details of the error as seem on the logs -- unai On Wed, Nov 13, 2019, at 10:02 PM, flaskee via Flask wrote: > Any tips on this one folks? > (I am stuck) > > ??????? Original Message ??????? > On Tuesday, November 12, 2019 10:14 AM, flaskee wrote: > >> Hello all: >> >> I'm just looking for pointers on where to check, in order to track this down. >> >> *The problem:* >> >> I have a production flask site, >> on Apache /2.4.38; Debian 10.1, using a virtualized Python3.5/HTML5 site. >> >> It works well! except that every few days it crashes with an Internal Server Error - 500. >> >> When "crashed", the site itself is still loaded in Apache2, >> as >> nmap -A >> nmap -sP >> nmap -A >> nmap -sP >> all report the host is loaded; >> and other static sites running on the same apache server still serve up just fine. >> >> It does not *appear* to be a coding error, >> as when it is running, >> I have negotiated to each and every page in the site, >> without causing a crash. >> >> Still, randomly, the site fails. >> >> I have been through: >> * the web sites' error.log >> * the web sites' acess.log >> * /var/log/apache2/error.log >> * /var/log/apache2/error.log.1 >> * /var/log/syslog >> and I'm not finding the cause. >> >> A >> sudo systemctl stop apache2.service >> sudo systemctl start apache2.service >> gets the site running again. >> >> >> Any tips on where else to check? >> >> Thank you! >> ** >> *The Error * >> Internal Server Error >> The server encountered an internal error or misconfiguration and was unable to complete your request. >> >> Please contact the server administrator at webmaster at mydomain.org to inform them of the time this error occurred, and the actions you performed just before this error. >> >> More information about this error may be available in the server error log. >> >> >> >> >> >> Sent with ProtonMail Secure Email. >> > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From linux4ms at gmail.com Wed Nov 13 16:23:27 2019 From: linux4ms at gmail.com (Ben Duncan) Date: Wed, 13 Nov 2019 15:23:27 -0600 Subject: [Flask] Report Writer In-Reply-To: <1573675393.3.1@gmail.com> References: <1573675393.3.1@gmail.com> Message-ID: Interactively, They would chose some selection criteria, I would call a module, then send the pdf . *Ben Duncan* DBA / Chief Software Architect Mississippi State Supreme Court Electronic Filing Division On Wed, Nov 13, 2019 at 2:03 PM Badri wrote: > Are you familiar with LaTeX? If so, you could use use normal Jinja2 > templates for .tex files, and generate pdfs from those resulting files. > > Are you planning to generate these reports live (ie. when users load the > page on your site) or only locally (eg. having a local Python script that > analyses your Flask and outputs the report to a PDF file)? > > ?Badri > > On Wed, Nov 13, 2019 at 13:17, Ben Duncan wrote: > > Any suggestion on a Report Write / PDF creator for Flask ? > > Thanks ... > > *Ben Duncan* > DBA / Chief Software Architect > Mississippi State Supreme Court > Electronic Filing Division > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From badrihippo at gmail.com Wed Nov 13 16:32:31 2019 From: badrihippo at gmail.com (Badri) Date: Thu, 14 Nov 2019 03:02:31 +0530 Subject: [Flask] Report Writer In-Reply-To: References: <1573675393.3.1@gmail.com> Message-ID: <1573680752.3.6@gmail.com> Hi, > Interactively, > > They would chose some selection criteria, I would call a module, then > send the pdf Okay. Since I haven't used LaTeX much I don't have a clear idea of how long it'll take, but for most cases (say, plaintext + a few images) the compilation won't take more than a second or so. So if you can make a template for a LaTeX file (using the Flask/Jinja2 templating system), you could do something like: Create a temporary folder (maybe using `tempfile.mkdtemp`)Write the LaTeX file to that (the result of render_template)Run pdflatex on that LaTeX file, maybe using `os.system` or a more fine-tuned commandOutput will be the same name with the .pdf extension: for example abc.tex will render to abc.pdfServe that abc.pdf file to the user. Hope that helps. Let me know if you need more info on the tempfile library, since I've been working with it in one of my projects. ?Badri -------------- next part -------------- An HTML attachment was scrubbed... URL: From flaskee at protonmail.com Thu Nov 14 10:31:51 2019 From: flaskee at protonmail.com (flaskee) Date: Thu, 14 Nov 2019 15:31:51 +0000 Subject: [Flask] Fw: Re: intermittent Internal Server Error on running flask site In-Reply-To: <20191113211140.GD4922@parsnip> References: <20191113211140.GD4922@parsnip> Message-ID: Thanks Adil I'll focus on the access log at the next crash. Sent with ProtonMail Secure Email. ??????? Original Message ??????? On Wednesday, November 13, 2019 4:11 PM, Adil Hasan wrote: > Hello, > I wonder. If you know rougly when it happens perhaps there's some info > in the access log to indicate what the request was at that time? It > could be that there's some request coming in that perhaps your code is > not able to handle and causes the 500 error? > hth > adil > > On Wed, Nov 13, 2019 at 09:02:28PM +0000, flaskee via Flask wrote: > > > Any tips on this one folks? > > (I am stuck) > > ??????? Original Message ??????? > > On Tuesday, November 12, 2019 10:14 AM, flaskee wrote: > > > > > Hello all: > > > I'm just looking for pointers on where to check, in order to track this down. > > > The problem: > > > I have a production flask site, > > > on Apache /2.4.38; Debian 10.1, using a virtualized Python3.5/HTML5 site. > > > It works well! except that every few days it crashes with an Internal Server Error - 500. > > > When "crashed", the site itself is still loaded in Apache2, > > > as > > > nmap -A > > > nmap -sP > > > nmap -A > > > nmap -sP > > > all report the host is loaded; > > > and other static sites running on the same apache server still serve up just fine. > > > It does not appear to be a coding error, > > > as when it is running, > > > I have negotiated to each and every page in the site, > > > without causing a crash. > > > Still, randomly, the site fails. > > > I have been through: > > > > > > - the web sites' error.log > > > - the web sites' acess.log > > > - /var/log/apache2/error.log > > > - /var/log/apache2/error.log.1 > > > - /var/log/syslog > > > and I'm not finding the cause. > > > > > > > > > A > > > sudo systemctl stop apache2.service > > > sudo systemctl start apache2.service > > > gets the site running again. > > > Any tips on where else to check? > > > Thank you! > > > The Error > > > Internal Server Error > > > The server encountered an internal error or misconfiguration and was unable to complete your request. > > > Please contact the server administrator at webmaster at mydomain.org to inform them of the time this error occurred, and the actions you performed just before this error. > > > More information about this error may be available in the server error log. > > > Sent with ProtonMail Secure Email. > > > Flask mailing list > > Flask at python.org > > https://mail.python.org/mailman/listinfo/flask From flaskee at protonmail.com Thu Nov 14 10:37:46 2019 From: flaskee at protonmail.com (flaskee) Date: Thu, 14 Nov 2019 15:37:46 +0000 Subject: [Flask] intermittent Internal Server Error on running flask si Message-ID: > ??????? Original Message ??????? > On Wednesday, November 13, 2019 4:12 PM, Unai Rodriguez wrote: > >> Yes you need to provide the actual details of the error as seem on the logs >> >> -- unai That's just it --- I am not seeing the errors on the logs. Am I missing a place to check? >>>> * the web sites' error.log >>>> * the web sites' acess.log >>>> * /var/log/apache2/error.log >>>> * /var/log/apache2/error.log.1 >>>> * /var/log/syslog >>>> and I'm not finding the cause. -------------- next part -------------- An HTML attachment was scrubbed... URL: From badrihippo at gmail.com Thu Nov 14 14:10:47 2019 From: badrihippo at gmail.com (badrihippo at gmail.com) Date: Fri, 15 Nov 2019 00:10:47 +0500 Subject: [Flask] Report Writer In-Reply-To: References: <1573675393.3.1@gmail.com> <1573680752.3.6@gmail.com> Message-ID: <1573758647.1309.1@smtp.gmail.com> On Thu, Nov 14, 2019 at 7:43 PM, Felix Ramirez wrote: > Sorry for entering in this conversation, but is my case too, > additionally to all i would like to send (print) that pdf file result > directly to the printer automatically without a user intervention. > That's vital for my application. > > Thanks in advance for any help you can provide me and regards to all. I haven't worked with printers, but this should also be possible by appending a command in the appropriate library to whatever script you're using. (To clarify, in the steps I listed above were meant to be automated, not done manually by the user). Let me know if you want more details. Not sure how much help I can be, but I'll do my best :) ?Badri -------------- next part -------------- An HTML attachment was scrubbed... URL: From prangara at akamai.com Fri Nov 15 18:49:57 2019 From: prangara at akamai.com (Rangarajan, Prakash) Date: Fri, 15 Nov 2019 23:49:57 +0000 Subject: [Flask] Duplicate log lines in python Message-ID: <84E1AEDC-2451-4938-B155-1A11906A9309@akamai.com> Hi, This is not a Flask question, but more of a python question. I have root logger configured and a rotating file handler added to the root logger. I am using some format string to display the log lines. However, once the log rotation is done, the format string is not used at all in the new log file. The log lines are printed as is without any format string. Has anyone encountered a similar issue ? Thanks, Prakash -------------- next part -------------- An HTML attachment was scrubbed... URL: From linux4ms at gmail.com Fri Nov 22 10:38:42 2019 From: linux4ms at gmail.com (Ben Duncan) Date: Fri, 22 Nov 2019 09:38:42 -0600 Subject: [Flask] Ok, what Am I doing wrong ?? Message-ID: I'm implementing CRUD under blueprints. I've a admin.py which contains the following routes: @admin.route('/groups', methods=['GET', 'POST']) def groups() : # Do some stuff form = Group_pick() groups = groups_table.query.order_by(groups_table.gp_office).all() .... @admin.route('/groupmaint/', methods=['GET', 'POST']) def groupmaint(gpid) : # Do some stuff .......... And the html in the groups has the following: ...... {% for group in groups %} {{ group.gp_groupid }} {{ group.gp_name }} {{ group.gp_type }} ..... When the edit is clicked, it DOES get to the : @admin.route('/groupmaint/', methods=['GET', 'POST']) However, all the css, js and other imported goodness is missing and not found. What do I need to do to correct this? *Thanks ...* *Ben Duncan* DBA / Chief Software Architect Mississippi State Supreme Court Electronic Filing Division -------------- next part -------------- An HTML attachment was scrubbed... URL: From linux4ms at gmail.com Fri Nov 22 10:49:29 2019 From: linux4ms at gmail.com (Ben Duncan) Date: Fri, 22 Nov 2019 09:49:29 -0600 Subject: [Flask] Ok, what Am I doing wrong ?? In-Reply-To: References: Message-ID: Stupid, stupid Missteaks ...... In my base.html, i need to have The slash before the static was missing ....... ARRGGG ..... *Ben Duncan* DBA / Chief Software Architect Mississippi State Supreme Court Electronic Filing Division On Fri, Nov 22, 2019 at 9:38 AM Ben Duncan wrote: > I'm implementing CRUD under blueprints. > I've a admin.py which contains the following routes: > > @admin.route('/groups', methods=['GET', 'POST']) > def groups() : > # Do some stuff > > form = Group_pick() > groups = groups_table.query.order_by(groups_table.gp_office).all() > .... > @admin.route('/groupmaint/', methods=['GET', 'POST']) > def groupmaint(gpid) : > # Do some stuff > .......... > > And the html in the groups has the following: > ...... > > {% for group in groups %} > > {{ group.gp_groupid }} > {{ group.gp_name }} > {{ group.gp_type }} > > > > ..... > When the edit is clicked, it DOES get to the : > @admin.route('/groupmaint/', methods=['GET', 'POST']) > > However, all the css, js and other imported goodness is missing and not > found. > > What do I need to do to correct this? > > *Thanks ...* > > > *Ben Duncan* > DBA / Chief Software Architect > Mississippi State Supreme Court > Electronic Filing Division > -------------- next part -------------- An HTML attachment was scrubbed... URL: From onlinejudge95 at gmail.com Sat Nov 30 08:55:19 2019 From: onlinejudge95 at gmail.com (Test Bot) Date: Sat, 30 Nov 2019 19:25:19 +0530 Subject: [Flask] Sessions and blueprints and Application context In-Reply-To: References: Message-ID: Hi all, The foremost thing to remember is that in flask, sessions are tied only to request context. Simply put, the session is available only during the lifetime of a request. On Thu, Oct 31, 2019, 7:48 PM Ben Duncan wrote: > Yes: > > my __init__.py > ------------------------------------------------------------- > import sys > > from flask import Flask, g, session > from flask_sqlalchemy import SQLAlchemy > > # Globally accessible libraries > pgdb = SQLAlchemy() > from sqlalchemy import MetaData > from flask_sqlalchemy import SQLAlchemy > metadata = MetaData() > > def create_app(): > """Initialize the core application.""" > #app = Flask(__name__, instance_relative_config=False) > #app = Flask(__name__) > app = Flask('mars') > > app.config.from_pyfile('config.cfg') > > session['myvar'] = 'MYVAR' > > ........ > > My wsgi.py > # Base wsgi application starter > > from mars import create_app > > app = create_app() > > if __name__ == "__main__": > app.run() > > > And then it gets: > > RuntimeError > > RuntimeError: Working outside of request context. This typically means > that you attempted to use functionality that needed an active HTTP request. > Consult the documentation on testing for information about how to avoid > this problem. > Traceback *(most recent call last)* > > - File "/data/flask/applications/mars/wsgi.py", line *9*, in > > app = create_app() > > - File "/data/flask/applications/mars/__init__.py", line *21*, in > create_app > > session['myvar'] = 'MYVAR' > > - File > "/opt/rh/python27/root/usr/lib/python2.7/site-packages/werkzeug/local.py", > line *351*, in __setitem__ > > self._get_current_object()[key] = value > > - File > "/opt/rh/python27/root/usr/lib/python2.7/site-packages/werkzeug/local.py", > line *307*, in _get_current_object > > return self.__local() > > - File > "/opt/rh/python27/root/usr/lib64/python2.7/site-packages/flask/globals.py", > line *38*, in _lookup_req_object > > raise RuntimeError(_request_ctx_err_msg) > > > RuntimeError: Working outside of request context. This typically means > that you attempted to use functionality that needed an active > > > I kinda thought session would be global but ... sigh ... > > I've tried the import from Flask_session Session stuff and no luck ... > > > *Ben Duncan* > DBA / Chief Software Architect > Mississippi State Supreme Court > Electronic Filing Division > > > On Thu, Oct 31, 2019 at 8:12 AM Josh Stephens wrote: > >> I believe you should just be able to import session from flask and use >> it. I thought session is stored as a global and so it can be used anywhere. >> Are you getting a specific error when trying to use sessions in your >> blueprint? >> >> >> On October 31, 2019 at 6:50:58 AM, Ben Duncan (linux4ms at gmail.com) wrote: >> >> Ok, given the previous example post form me (Help WIth BluePrints), >> How does on go about accessing "session" in the bluprinted view? >> >> Do I need to something more in my "__init__.py" ? Am I missing some import >> in my view ? >> >> As Always thanks ... >> >> >> *Ben Duncan* >> DBA / Chief Software Architect >> Mississippi State Supreme Court >> Electronic Filing Division >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From badrihippo at gmail.com Sat Nov 30 09:54:19 2019 From: badrihippo at gmail.com (Badri Sunderarajan) Date: Sat, 30 Nov 2019 20:24:19 +0530 Subject: [Flask] Sessions and blueprints and Application context In-Reply-To: References: Message-ID: <7ea1b18e-f818-cf15-8f5e-e843f4ed84b1@gmail.com> Yes, session can only be accessed within a request context, which would in practical terms mean it needs to be called from within a view. Each client (read: browser) which loads the page gets its own session, so it doesn't make sense to define a "global" session for everyone. Depending on what you're trying to do, you could set the session variable within a view like @app.route('/') def home(): session['myvar'] = 'MYVAR' # sets variable for this particular session return 'Hello, session!' On the other hand, if you want the variable to be global for the whole app, you should probably be setting app.config or something instead of using session variables. Hope that helps! Badri -------------- next part -------------- An HTML attachment was scrubbed... URL: From linux4ms at gmail.com Sat Nov 30 13:40:17 2019 From: linux4ms at gmail.com (Ben Duncan) Date: Sat, 30 Nov 2019 12:40:17 -0600 Subject: [Flask] Sessions and blueprints and Application context In-Reply-To: <7ea1b18e-f818-cf15-8f5e-e843f4ed84b1@gmail.com> References: <7ea1b18e-f818-cf15-8f5e-e843f4ed84b1@gmail.com> Message-ID: Awesome, thanks! *Ben Duncan* DBA / Chief Software Architect Mississippi State Supreme Court Electronic Filing Division On Sat, Nov 30, 2019 at 8:54 AM Badri Sunderarajan wrote: > Yes, session can only be accessed within a request context, which would > in practical terms mean it needs to be called from within a view. Each > client (read: browser) which loads the page gets its own session, so it > doesn't make sense to define a "global" session for everyone. > > Depending on what you're trying to do, you could set the session variable > within a view like > > @app.route('/') > def home(): > session['myvar'] = 'MYVAR' # sets variable for this particular session > return 'Hello, session!' > > On the other hand, if you want the variable to be global for the whole > app, you should probably be setting app.config or something instead of > using session variables. > > Hope that helps! > > Badri > > -------------- next part -------------- An HTML attachment was scrubbed... URL: