Skip to content

Instantly share code, notes, and snippets.

@vishwassharma
Last active December 23, 2015 15:09
Show Gist options
  • Save vishwassharma/6654145 to your computer and use it in GitHub Desktop.
Save vishwassharma/6654145 to your computer and use it in GitHub Desktop.

Revisions

  1. vishwassharma revised this gist Oct 3, 2013. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions dispatch.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    #!/usr/local/bin/python2.7
    import sys, os

    home_path = "/home/content/t/e/c/techbudconsult/"
    pyenv_path = "pyenv/lib/python2.7/site-packages"
    file_path = "swarjneeti/myproject"
    log_path = "swarjneeti/lot.txt"

    sys.path += [os.path.join(home_path, pyenv_path)]
    sys.path += [os.path.join(home_path, file_path)]
    os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'

    from flup.server.fcgi import WSGIServer
    from django.core.handlers.wsgi import WSGIHandler
    WSGIServer(WSGIHandler()).run()
  2. vishwassharma revised this gist Oct 3, 2013. 2 changed files with 8 additions and 20 deletions.
    20 changes: 0 additions & 20 deletions gistfile2.txt
    Original file line number Diff line number Diff line change
    @@ -1,20 +0,0 @@
    #!/usr/local/bin/python2.7

    from traceback import format_exc
    import sys
    import os
    import site

    home_path = "/home/content/t/e/c/techbudconsult/"
    pyenv_path = "pyenv/lib/python2.7/site-packages"
    file_path = "swarjneeti/meravote"
    log_path = "swarjneeti/lot.txt"
    try:
    site.addsitedir(os.path.join(home_path,pyenv_path))
    site.addsitedir(os.path.join(home_path,file_path))
    os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
    from django.core.servers.fastcgi import runfastcgi
    runfastcgi(method="threaded", daemonize="false")
    except Exception:
    open(os.path.join(home_path,log_path), "w").write(format_exc())
    raise
    8 changes: 8 additions & 0 deletions godaddy
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    AddHandler fcgid-script .fcgi
    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /

    # everything else sent to django
    RewriteRule ^(dispatch.py/.*)$ - [L]
    RewriteRule ^(.*)$ dispatch.py/$1 [L]
  3. vishwassharma revised this gist Oct 3, 2013. 2 changed files with 43 additions and 0 deletions.
    23 changes: 23 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    #!/usr/local/bin/python2.7

    from traceback import format_exc

    import sys, os
    import site

    try:
    site.addsitedir("/home/content/t/e/c/techbudconsult/pyenv/lib/python2.7/site-packages")
    site.addsitedir("/home/content/t/e/c/techbudconsult/swarjneeti/meravote")

    # Add a custom Python path for your project
    #sys.path.insert(0, "/home/content/t/e/c/techbudconsult/swarjneeti/meravote")

    # Set the DJANGO_SETTINGS_MODULE environment variable.
    # This should match the name for the project you added to the path above
    os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

    from django.core.servers.fastcgi import runfastcgi
    runfastcgi(method="threaded", daemonize="false")
    except Exception:
    open("/home/content/t/e/c/techbudconsult/swarjneeti/lot.txt", "w").write(format_exc())
    raise
    20 changes: 20 additions & 0 deletions gistfile2.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #!/usr/local/bin/python2.7

    from traceback import format_exc
    import sys
    import os
    import site

    home_path = "/home/content/t/e/c/techbudconsult/"
    pyenv_path = "pyenv/lib/python2.7/site-packages"
    file_path = "swarjneeti/meravote"
    log_path = "swarjneeti/lot.txt"
    try:
    site.addsitedir(os.path.join(home_path,pyenv_path))
    site.addsitedir(os.path.join(home_path,file_path))
    os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
    from django.core.servers.fastcgi import runfastcgi
    runfastcgi(method="threaded", daemonize="false")
    except Exception:
    open(os.path.join(home_path,log_path), "w").write(format_exc())
    raise
  4. vishwassharma revised this gist Oct 3, 2013. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion dispatch.fcgi
    Original file line number Diff line number Diff line change
    @@ -8,9 +8,11 @@ import site
    # sys.path.insert(0, '/home/vish0wass/local/lib/python2.6/site-packages')
    try:
    site.addsitedir('/home/vishwass/local/lib/python2.6/site-packages')
    os.environ['DJANGO_SETTINGS_MODULE'] = 'myproj.settings'
    site.addsitedir('/home/vishwass/website')
    os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
    from django.core.servers.fastcgi import runfastcgi
    runfastcgi(method="threaded", daemonize="false")
    except Exception:
    open("/home/vishwass/website/lot.txt", "w").write(format_exc())
    raise

  5. vishwassharma revised this gist Oct 3, 2013. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions .htaccess
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ AddHandler fcgid-script .fcgi
    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    RewriteRule ^(media/.*)$ - [L]
    RewriteRule ^(adminmedia/.*)$ - [L]
    RewriteCond %{REQUEST_URI} !(dispatch.fcgi)
    RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]
    RewriteRule ^static/(.*)$ static/$1 [QSA,L]
    RewriteCond %{REQUEST_URI} !(myproject.fcgi)
    RewriteRule ^(.*)$ myproject.fcgi/$1 [QSA,L]

  6. vishwassharma revised this gist Sep 22, 2013. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion fixes
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,5 @@
    chmod 644 .htaccess
    chmod 744 dispatch.fcgi
    chmod 744 dispatch.fcgi

    chmod 600 settings.py
    chmod 600 local_settings.py
  7. vishwassharma created this gist Sep 21, 2013.
    8 changes: 8 additions & 0 deletions .htaccess
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    AddHandler fcgid-script .fcgi
    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    RewriteRule ^(media/.*)$ - [L]
    RewriteRule ^(adminmedia/.*)$ - [L]
    RewriteCond %{REQUEST_URI} !(dispatch.fcgi)
    RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]
    16 changes: 16 additions & 0 deletions dispatch.fcgi
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #!/usr/bin/python2.6
    from traceback import format_exc
    import sys
    import os
    import site

    # Make sure to change 'username' to your username!
    # sys.path.insert(0, '/home/vish0wass/local/lib/python2.6/site-packages')
    try:
    site.addsitedir('/home/vishwass/local/lib/python2.6/site-packages')
    os.environ['DJANGO_SETTINGS_MODULE'] = 'myproj.settings'
    from django.core.servers.fastcgi import runfastcgi
    runfastcgi(method="threaded", daemonize="false")
    except Exception:
    open("/home/vishwass/website/lot.txt", "w").write(format_exc())
    raise
    2 changes: 2 additions & 0 deletions fixes
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    chmod 644 .htaccess
    chmod 744 dispatch.fcgi