Skip to content

seenivasanpalanisamy/simple_django_app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple_django_app

SETUP:

Installing dependencies, initialization:

pip install --upgrade -r requirements.txt   # install python dependencies 
python manage.py migrate    # initialize the django mysql database

CONFIG:

Set all environment variables needed

eg. DEBUG_LEVEL,DB configurations,HOST etc..

NGINX CONFIG:

Add the following to nginx.conf file

server {
    # the port your site will be served on
    listen      80;
    server_name host_name;   # substitute by your FQDN and machine's IP address
    charset     utf-8;

    #Max upload size
    client_max_body_size 75M;   # adjust to taste

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

RUN:

python manage.py runserver

EXAMPLE:

This is an sample user commenting application with little features for create,update,delete operation.

Some apis as follwed

http://localhost:8000/details/
http://localhost:8000/home/
http://localhost:8000/create/?name=test1&comment=My1stdjangoapp&title=test
http://localhost:8000/update/?name=test1&comment=My1stdjangoapp&title=test&new_comment=My2ndjangoapp
http://localhost:8000/delete/?name=test1&comment=My1stdjangoapp&title=test

USED HOSTED MYSQL:

Temporarily used freemysqlhosting site for db.

'ENGINE': 'django.db.backends.mysql',
'NAME': 'sql12234563'
'USER': 'sql12234563',
'PASSWORD': 'V58C8ZFlFr',
'HOST': 'sql12.freemysqlhosting.net',
'PORT': '3360'

CLOUD SETUP:

Permanent setup as aws EC-2 instance.

1.Create an cloud instance with python,mysql installed
2.Clone the repo with git commands
3.Install nginx and uwsgi and config them to run multiple workers.
4.Run the django server with the help of uWSGI.

uwsgi --http :8000 --module simple_django_app.wsgi --master --processes 100 --threads 2

TASK COMPLETED:

1.Cloud setup
2.django application
3.Hosted the server in cloud
4.Git Repository
5.Rest api's

About

done for Interview

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors