Flask

Flask Admin - how to set form_edit_rules or form_create_rules based on role of user?

梦想与她 提交于 2021-01-20 12:07:16
问题 I am making simple ticketing system for medium-sized organization using Flask and sqlite together with SQLAlchemy. For backend managing of data I use Flask-Admin. The User and Ticket table looks like this: class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) role = db.Column(db.Integer, default=0) vmc_kom = db.Column(db.String(20)) name = db.Column(db.String(30), nullable=False) phone = db.Column(db.String, default="not") email = db.Column(db.String(40), nullable

Retrieving data from RDS gives AttributeError: 'sqlalchemy.cimmutabledict.immutabledict' object has no attribute 'setdefault'

為{幸葍}努か 提交于 2021-01-20 09:34:26
问题 I would like to retrieve user data from RDS whenever the API endpoint {{url}}/api/users/login is called to authenticate users, however, I am currently having issues with retrieving data from RDS. Error stacktrace This is the full stacktrace of the error: Current package versions Flask==1.1.2 Flask-Cors==3.0.10 flask-marshmallow==0.14.0 Flask-Migrate==2.5.3 Flask-RESTful==0.3.8 Flask-SQLAlchemy==2.4.4 marshmallow==3.10.0 marshmallow-sqlalchemy==0.24.1 SQLAlchemy==1.4.0b1 python==3.7 My

基于Ubuntu20.10学习python虚拟环境搭建

北城以北 提交于 2021-01-18 18:26:58
在工程开发前,往往需要解决模块的版本问题,比如projectA需要用到Python2.7+flash0.10 和projectB需要用到Python3+flask1.0,创建Python的虚拟环境就可以很好的解决这个问题,从而 实现环境独立,套件升级并不会影响其他应用。​​​​​​​ ​​​​​​​ 环境安装 在ubuntu的terminal下执行以下命令,进行虚拟环境安装: # virtualenv 用于创建虚拟环境 sudo pip install virtualenv # virtualenvwrapper 提供了高效的执行命令 sudo pip install virtualenvwrapper 安装结束后,可能会出现mkvirtualenv not foud错误,需要配置以下: # 在terminal下执行 # 1.创建用于放置虚拟文件的隐藏目录virtualenvs mkdir $HOME/.virtualenvs # 2. 打开~/.bashrc添加如下内容 export WORKON_HOME=$HOME/.virtualenvs source /usr/local/bin/virtualenvwrapper.sh # 3. 保存退出2后,回到terminal执行 source ~/.bashrc 执行后可以在Home下看到如下图(ctrl+h显示隐藏文件):

Flask does not load CSS file..?

半城伤御伤魂 提交于 2021-01-18 05:58:04
问题 So the problem I'm having is that my web app only sometimes loads the css file and it uses the same css file data that was loaded even if I make edits to the css file and even when I delete the file. I have no clue what's going on. I have noticed that when it does load the css correctly the following message is displayed: 127.0.0.1 - - [08/Jun/2015 14:46:19] "GET /static/style.css HTTP/1.1" 200 My style.css file is under a folder named static and in my html file I have <link type='text/css'

学习Python必去的8个网站!

元气小坏坏 提交于 2021-01-18 05:54:12
作为一个现时代的程序员初学者,除了看书之外,互联网的学习手段也是断不能少的! 以下这些网站,虽说不上全方位的满足你的需求,但是大部分也都能! 0.国外的大神GitHub : https://github.com/pypa/pipenv 学习Python必去的8个网站! gitHub是一个面向开源及私有软件项目的托管平台,就算现在已经被微软重金收购,也丝毫不影响大家对它的爱! 1.Python Code Examples: https://www.programcreek.com/python/ 学习Python必去的8个网站! 在这里你可以搜索到你想要学习的代码示例,通过例子来进行模仿学习。 2.python中文学习大本营: http://www.pythondoc.com/ 这里有Flask资料大全,如果你需要,在这里可以找到你想要的几乎所有的教程。 学习Python必去的8个网站! 3.1Python 3 Module of the Week : https://pymotw.com/3/ 3.2Python Module of the Week: https://pymotw.com/2/ image Python 3 Module of the Week系列文章,每篇介绍一个 Python 标准库的使用. 4. Welcome to Python for you and

Flask+AJAX+Jquery+JINJA to dynamically update HTML Table

风流意气都作罢 提交于 2021-01-18 04:45:21
问题 I want to display the Port status dynamically. I don't want to reload the page to see a new value. I know how to get the Port status in Python(using uiApi() ). Right now I render a template with the value and show the values in HTML table. How can I continually update the table with a value from Flask? I have the AJAX and jquery available. The Flask Code is give below: @app.route('/') def show_auth(): tData = uiApi() .. return render_template('show_auth.html', tMain=tData) The {{field}} in

Passing input from html to python and back

拥有回忆 提交于 2021-01-18 04:37:02
问题 I need to make a webpage for an assignment, it doesn't have to be uploaded to the web, I am just using a local .html file. I did some reading up and came up with the following html and python: <!DOCTYPE html> <html> <head> <title> CV - Rogier </title> </head <body> <h3> Study </h3> <p> At my study we learn Python.<br> This is a sall example:<br> <form action="/cgi-bin/cvpython.py" method="get"> First Name: <input type="text" name="first_name"> <br /> Last Name: <input type="text" name="last

Passing input from html to python and back

烈酒焚心 提交于 2021-01-18 04:34:09
问题 I need to make a webpage for an assignment, it doesn't have to be uploaded to the web, I am just using a local .html file. I did some reading up and came up with the following html and python: <!DOCTYPE html> <html> <head> <title> CV - Rogier </title> </head <body> <h3> Study </h3> <p> At my study we learn Python.<br> This is a sall example:<br> <form action="/cgi-bin/cvpython.py" method="get"> First Name: <input type="text" name="first_name"> <br /> Last Name: <input type="text" name="last

How can I create a python webhook sender app?

风格不统一 提交于 2021-01-16 04:14:05
问题 This is a follow up question to this post. I have a data warehouse table exposed via xxx.com\data API endpoint I have been querying this table using the following code and parsing it into a dataframe as follows; import requests import json import http.client import pandas as pd url = "xxx.com\data?q=Active%20%3D1%20and%20LATITUDE%20%3D%20%20%220.000000%22%20and%20LONGITUDE%20%3D%20%220.000000%22&pageSize =300" payload = {} headers = {'Authorization': access_token} response = requests.request(

flask利用session身份伪造

半城伤御伤魂 提交于 2021-01-15 15:37:48
想研究很久了,这次终于初步了解了flask session伪造(得知道密钥)。 python2和python3 session解密不一样,而且不都是base64,脚本 https://github.com/ZhangAiQiang/Flask/tree/master/%E8%A7%A3%E5%AF%86session%E8%84%9A%E6%9C%AC 参考文章: https://www.cnblogs.com/apossin/p/10083937.html ①首先需要知道的信息 flask是把session存在客户端的,而且只经过base64编码和用密钥签名,虽然没有有签名不可以伪造session,但是有很多信息我们可以直接从session解码找出来。 ②session伪造源码( https://github.com/ZhangAiQiang/Flask/tree/master/flask-session%E8%BA%AB%E4%BB%BD%E4%BC%AA%E9%80%A0%E7%AE%80%E5%8D%95%E6%BA%90%E7%A0%81 ) from flask import Flask,session,render_template,request,render_template_string app=Flask(__name__) app.config[