Horje
redirect user based on input with python cgi code Code Example
redirect user based on input with python cgi code
 # Import modules for CGI handling 

    import cgi, cgitb 

    # import pymongo module for connecting to mongodb database
    import pymongo
    from pymongo import MongoClient

    # Create instance of FieldStorage 
    form = cgi.FieldStorage() 

    # creating a mongo client to the running mongod instance
    # The code will connect on the default host and port i.e 'localhost' and '27017'
    client = MongoClient()

    # selecting the database mydb 
    db_mydb = client.mydb

    # selecting the collection user
    collection_user = db_mydb.user

    #print "Content-type:text/html\r\n\r\n"

    # Get data from fields
    email = form.getvalue('login-username')
    password  =     form.getvalue('login-password')

    #checking whether user inputs are correct or not
    existence_query = collection_user.find_one({"_id":email,"password":password})


    if(existence_query):
        print "Location:http://localhost/mongo/index.html\r\n"
        print "Content-type:text/html\r\n\r\n"
    else:
        print "Location:http://localhost/mongo/index.html\r\n"
        print "Content-type:text/html\r\n\r\n"




Python

Related
python break out of function Code Example python break out of function Code Example
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 40: invalid start byte Code Example UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb0 in position 40: invalid start byte Code Example
Ordering column names sensibly in pandas Code Example Ordering column names sensibly in pandas Code Example
weigted average in pandas Code Example weigted average in pandas Code Example
python multilevel list comprehension Code Example python multilevel list comprehension Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7