Python Daily
2.57K subscribers
1.48K photos
53 videos
2 files
38.8K links
Daily Python News
Question, Tips and Tricks, Best Practices on Python Programming Language
Find more reddit channels over at @r_channels
Download Telegram
What is up with this return redirect line?

main is just my homepage and / is the url. For some reason, I can't get signUp to return back to the homepage after finishing.
return redirect(function) goes return redirect(main) (since thats the name of home being rendered.

I can also confirm 'here' and 'Registered' get printed. Also, in my terminal, i get

127.0.0.1 - - [23/Apr/2018 23:13:51] "GET / HTTP/1.1" 200 -

Which means it SHOULD be going to home, because I get the same line when I just click the home link on the page. It redirects too. What happens with the flask is it just stays on the login page. Nothing else, no errors thrown. Just sits there.

@app.route("/")
def main():
return render_template('Senty.html')

@app.route('/signUp',methods=['POST','GET'])
def signUp():
# still need to create signup class and transfer below code to new file
conn = mysql.connect()
cur = conn.cursor()

try:
_name = request.form['inputName']
_email = request.form['inputEmail']
_password = request.form['inputPassword']

# validate the received values
if _name and _email and _password:

cur.callproc('sp_createUser',(_name,_email,_password,))
print ("Registered")
data = cur.fetchall()

conn.commit()
json.dumps({'message':'User created successfully !'})
print('here')
return redirect(url_for('main'))

#else:
#return json.dumps({'html':'<span>Enter the required fields</span>'})

#except Exception as e:
#return json.dumps({'error':str(e)})

finally:
cur.close()
conn.close()

@app.route('/showSignIn')
def showSignIn():
return(render_template('login.html'))

I'm not sure where to go. I feel like I've tried everything.


/r/flask
https://redd.it/8ei5hq
A Visual Basic for Applications precompiler written in python.

I’ve just created an official release of a VBA precompiler written in python.

# What my Project Does

For those who don’t know, in VBA you can have precompiler blocks to change things for different OSs or VBA versions.
For example, to change the function signature for a new windows version:

#if Win64 Then
Function foo(Bar, Baz)
#Else
Function Foo(Bar)
#Endif

The problem with this is, if you want to scan raw source code, you can’t just ignore the precompiler lines, because now the code looks like you’ve tried to define the same function twice, and one was never ended.

This tool takes environment variables that the user provides, and will comment out any lines that need to be skipped, creating 100% valid precompiled code. It even performs the comparisons, and arithmetic operations specified in the VBA specification.

# Target Audience

People interested in malware prevention, static analysis, and Linting may find it helpful. Also, useful if you are interested in learning about compilers, ANTLR, and code parsing.

# Limitations
It is currently missing the standard library functions, like Cbool(), Abs(), etc. I’m guessing these are never called by users in the precompiler phase.

/r/Python
https://redd.it/1ay6lt1