Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.9K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
[Ask Flask] Is it possible to Auto generate a form thats based off a Database Schema onto a web page using WTForms and SQLAlchemy?

I want to make a simple web application that is a able to look at the fields of a database and generate a form onto a page for a user to fill in.

Im relatively new to Flask and thought It would be maybe possible by using SQLAlchemy and WTForms but wanted to get a second opinion as to what might be the best and easiest way to do this. Also, if you know any documentation that might be of use to me to get this done, can you please share. Thanks!

/r/flask
https://redd.it/696ivi
[Ask Flask] When running from terminal script, it opens two webpages instead of one

Hello, I've found almost the same question on stackoverflow but without accepted response. This is unresolved and after 3 hours I'm at my limit.

What do I have:

- `run.py` in `/this/location/run.py`
- `issues` symbolic link in `~/bin/issues --> /this/location/run.py`

What I want:

- user opens a terminal and writes `issues`, that starts a flask app and opens a google-chrome browser (one).

What it does:

- user opens a terminal, writes `issues`, that stats flask app, opens a browser, re-starts flask I think and opens another browser...

**`run.py`**:

#!/usr/bin/env python3
from flask import Flask
import webbrowser
from multiprocessing import Process
app = Flask(__name__)

@app.route('/')
def index():
return 'Index Page'

@app.route('/hello')
def hello():
return 'Hello, World'

def start_server(url):
print("START SERVER")
app.run(host="{}".format(url), debug=True)

def start_browser(url, port):
webbrowser.open_new("http://{url}:{port}/".format(url=url, port=port))

def main():
url, port = '0.0.0.0', '5000'
p1 = Process(target=start_server, args=(url,))
p2 = Process(target=start_browser, args=(url, port))

processes = list()
processes.append(p1)
processes.append(p2)

for p in processes:
p.start()

if __name__ == '__main__':
main()

**Terminal output:**:

(SonGokussj4@my_secret_machine) - (~) $ issues
START SERVER
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
* Restarting with stat
START SERVER
* Debugger is active!
* Debugger pin code: 165-476-411
127.0.0.1 - - [04/May/2017 16:53:48] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [04/May/2017 16:53:49] "GET / HTTP/1.1" 200 -

Anyone knows what the hell is happening?

/r/flask
https://redd.it/6980g8
Why does default=False have to be explicitly set for BooleanField in models.py?

I have a number of fields in my models.py file which have "= models.BooleanField()" set.

However, 'makemigrations' is rejecting them, saying that the non-nullable field needs a default. I thought the default for BooleanField was False?

I can fix the problem by adding (default=False) to every single BooleanField but it seems ridiculous that I have to do this.

Might there be a simpler way to solve this problem?

Robert

/r/django
https://redd.it/699k83
How have you automated your life with python? (if you have)

Hi, I'm learning python and need some inspiration. I saw another post on here but it was over 2 years old.

/r/Python
https://redd.it/69ba93
[AF] New project, site like Issue Tracker

Hello! For starters, I did do the `Mega-tutorial Part I` and some other tutorials like 2 months ago. But still don't understand a lot of things.

**What I need:**

- user writes into terminal`issues`, this starts a flask app in our company shared local diskspace where it will be saved.
- Chrome/Firefox will open and asks the user to enter `ANSA` and `META` PDF files (he will click on dots and choose the file, not write a path. Too complicated for them.
- Then they push a `process` button that will call a function `pdf_to_issues(ANSAfile, METAfile)` saved in some specific folder
- this script returns a LOT of issues in form of list: `['ANSA-34123', 'ANSA-35349', 'META-13303', '#44001', ...]`
- Flask would somehow load this list and compare it with already saved issues. If some of them are the same, it will tag them as `resolved`
- The user will see a list of issues that were resolved.
- Then he click on `View all issues` which will display a table of all saved issues and give red (unresolved) and green (resolved).
- In the future, user can edit those issues and modify `description`, `priority`.

[Here is a picture](http://i.imgur.com/6GuNPnJ.png) I did to somehow illuminate what I want.

I would be *grateful* for any help, pointers, where do I start, what libraries do I use, what articles do I read, what do I expect that would go wrong, anything. This will be my first Flask bigger project. Any help would be really appreciated.

Thanks!!!



/r/flask
https://redd.it/69atvr
[Ask Flask] is it possible to POST without moving?

I'm working on a mild app that uses form POST to send data to Flask, but can't figure out if there's a way to post in pure HTML / CSS without moving to the new page, being the POST page.

Is there?

/r/flask
https://redd.it/697mhq
Require login for entire site?

I found [this](http://onecreativeblog.com/post/59051248/django-login-required-middleware#code) blogpost, but it's very old. Is this still a viable approach or are there better alternatives?


/r/djangolearning
https://redd.it/67mjq9
Can Jupyter (or similar) replace Excel?

I hope this question fit's here. If it's a dumb question, tell me and I'll delete it.

1. I don't want to encourage a war.
2. **I admit, that I don't know Jupyter or Excel well!**

Both programs can be used to analyze data.

*As far as I know* Jupyter, it's a bit like Python in the interactive mode, with some extra amenities and easy plotting of graphs. It's mostly used by scientists.

*As far as I know* in Excel, you have files that consist of big tables and in each cell there can either be data, computations, or some explanations like column names. You can probably also connect to dedicated data files/databases and dedicated files with code. You can also use it to make graphs. It's used in "business".

As I said: That is probably not entirely true - that's why I'm asking.

I'm a student of computer science and we learn that you should separate data, metadata, and computation and that having "locations" for data is "bad". In the sense that "goto [line]" commands are bad and pointers are bad if you want maintainability and productivity (of course pointers have their place). To me it seems like Excel makes these errors. (I know that you can give cells names.)

Jupyter can't be used to store and edit structured data (well), I think.

Is anyone of you familiar with both technologies?
What are some good use cases for Excel?
If Jupyter isn't it, do you know other potential replacements for Excel?

…Excel is reactive/"live", which is nice – you don't have to press "run".

/r/IPython
https://redd.it/69nmpa
quickest way to browse web-scraped data?

Hello there.
So, I'm looking for a house, so I wrote a crawler that scrape data from several local real estate agencies and do some filtering (number of rooms, price, etc). All data is currently saved in a sqlite database.

Now, the problem is: what is the quickest way to present the data? I was thinking about making a small Flask-based website to browse the data, deleted records, etc. but that seems a lot of work for an application which will have just two users (me and my GF).

Is there any framework which can help me?

Thanks!

/r/Python
https://redd.it/69mixz
A forensic toolkit in Python

https://github.com/MonroCoury/Forensic-Tools

A project I been working on, a bunch of Python scripts that facilitate digital forensic analysis.


Features:

-Document metadata extraction.

-Image EXIF metadata extraction.

-Firefox database parsing, including extracting cookies, history, form history, Google searches, and downloads. Can limit results to a certain time range.

-Skype database parsing, including Account details, contacts with full details, call log, and messages. Ability to look for messages/calls within a given time range and/or from/to a specific partner.

-Results are saved to html tables with row background highlighting for easier reading.

-I'm trying to make it as simple and easy to use as possible. Firefox scanner attempts to find the default databases across different platforms on its own should the user forget to point it.


Still a work in progress. Planned features:

-Chrome browsing data extraction

-Internet Explorer browsing data extraction

-Network traffic analysis

-Windows registry parsing

-PDF, zip, and rar password cracking

Feedback is most welcome!

/r/Python
https://redd.it/69nc8c