Python Forum

Full Version: Forms, python, passlib and other questions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to learn about forms and server side scripting with python. I read the w3c forms tutorial and then watched the tutorials here: https://pythonschool.net/server-side-scr...de-script/ where he shows how to capture form data, and then goes on to show how to use a MySQL DB.

So I got things working, and have apache, MySQL and MySQL connector installed and working. I can type a name in and the code checks (using a simple name lookup) if it is in the DB, and if not adds it.

So as part of this I decided to try to make a login type form, with username and password - this works, but was stored plaintext, and I wanted to go further so read about hashing, and installed passlib with pip, and also did pip install passlib[argon2].

Now if I write a program and run it locally it works fine, but when I run the localhost code it says module not found. I think it is because the cgi-bin directory is in /usr/lib/cgi-bin. Does anyone know how I can fix this?

Other questions: I have heard about SQL injection and watched a video on youtube where he showed how it works and how he could then get data out of the DB. So I thought there would be some sort of SQL validator, either server side with python, or client side with javascript, but I couldn't find one. Obviously this is all running locally but in learning I want to do it right, so do I need to worry about this with MySQL and the python MySQL connector package?

For these next questions, I don't need code, more pointing in the right direction so I know where to look to figure them out. So I have seen forms where when you hover over them, something pops up to give you info about that field. Is this javascript or come css trickery?

Another thing I was thinking about trying to implement is the distance between users, so they could enter a location, and then it would tell them the distance to another user (like online dating sites do, according to my sister who loves them!) so I wondered how this was done. Also how do sites geolocate via IP?

If you have any other tips or advice for me regarding this area of python I would be happy to hear them.

I knew I'd forget a question: I have seen sign-up forms where, when you type in a username, it checks if it is available, is this javascript or how is this done?
You are looking at dead stuff like CGI and XAMPP,WAMP(for Python).
Modern web-development today in Python is done bye using eg Flask or Django.
Both of these has build web-server for local development,so no need to use XAMPP,WAMP.

I want a back story look at Why is WSGI necessary?.
WSGI is all written in Python to overcome shortcoming of CGI and other stuff.
So today is all Python web-framework build on WSGI in bottom.

Look at tutorial for Flask and Django,i have one here you can look with Flask.
Working with Flask is good start in web-development for Python,you are closer to HTML,CCS,JavaScript it's like modern way of the old CGI.
Django has a lot stuff build in even if you need it or not.
That said both are good modern and mature web-frame work for Python.