Skip to content

Latest commit

 

History

202 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Cryptography-Project

Environment initialization

Windows: MyProjectEnvt\Scripts\activate.bat

Linux: source MyProjectEnvt/bin/activate Once the environment is activated, you will see this result in the command prompt:

Windows: (MyProjectEnvt) C:\Users\...\Cryptography-Project>

Linux: (MyProjectEnvt) $ /home/.../Cryptography-Project$

Install dependencies

Windows: (MyProjectEnvt) C:\Users\...\Cryptography-Project> py -m install Django

Linux: (MyProjectEnvt) $ /home/.../Cryptography-Project$ pip install Django

This repo has already set up a project - Cryptography-Project/website.

To run the project, you need to go to the directory Cryptography-Project/website and run the command: (MyProjectEnvt) C:\Users\...\Cryptography-Project\website> py manage.py runserver

This repo has already set up an app - Cryptography-Project/website/myfirstapp

Connect to the database

First, we need to install PyMongo:

pip install pymongo
pip install dnspython

Using PyMongo, we can concurrently run multiple databases by specifying the right database name to the connection instance.

Let us create a sample pymongo session. There are two approaches for this:

  1. We can create a client in the utils file that can be used by any view that wants to interact with MongoDB. Create a utils.py file in your project folder (same location as manage.py) and instantiate the client:
from pymongo import MongoClient
def get_db_handle(db_name, host, port, username, password):

 client = MongoClient(host=host,
                      port=int(port),
                      username=username,
                      password=password
                     )
 db_handle = client['db_name']
 return db_handle, client

This method can then be used in ./myfirstapp/view.py.

  1. Another approach to get the connection is to use the connection_string:
from pymongo import MongoClient
client = MongoClient('connection_string')
db = client['db_name']

where

connection_string = "mongodb+srv://<username>:<password>@<cluster-address>/test?retryWrites=true&w=majority"

For example:

makemyrx_db = client['sample_medicines']
#collection object
medicines_collection = makemyrx_db['medicinedetails']

FIX BUG :

OperatorOR = Literal("OR").setParseAction(downcaseTokens) | Literal("or")
NameError: name 'downcaseTokens' is not defined

The problem seems to be the later version of pyparsing module no longer has that attribute. Downgrading it works for me. run:

pip install pyparsing==2.4.2

Additional packages

pip install django-otp
pip install pyotp
INSTALLED_APPS = [
    # ...
    'django_otp',
    'django_otp.plugins.otp_totp',
    # ...
]
MIDDLEWARE = [
    # ...
    'django_otp.middleware.OTPMiddleware',
    # ...
]

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages