Skip to content

Instantly share code, notes, and snippets.

View osharim's full-sized avatar
🎯
Focusing

Omar Hernandez osharim

🎯
Focusing
  • México
View GitHub Profile
@osharim
osharim / backbone_pushstate_router.js
Created April 7, 2016 04:28 — forked from tbranyen/backbone_pushstate_router.js
hijack links for pushState in Backbone
// All navigation that is relative should be passed through the navigate
// method, to be processed by the router. If the link has a `data-bypass`
// attribute, bypass the delegation completely.
$(document).on("click", "a[href]:not([data-bypass])", function(evt) {
// Get the absolute anchor href.
var href = { prop: $(this).prop("href"), attr: $(this).attr("href") };
// Get the absolute root.
var root = location.protocol + "//" + location.host + Application.root;
// Ensure the root is part of the anchor href, meaning it's relative.
from django import http
from django.conf import settings
"""
Put this file in a directory called, eg, 'middleware,' inside your django
project. Make sure to create an __init__.py file in the directory so it can
be included as a module.
Set the values for
XS_SHARING_ALLOWED_ORIGINS
XS_SHARING_ALLOWED_METHODS
class CORSResource(object):
"""
Adds CORS headers to resources that subclass this.
"""
def create_response(self, *args, **kwargs):
response = super(CORSResource, self).create_response(*args, **kwargs)
response['Access-Control-Allow-Origin'] = '*'
response['Access-Control-Allow-Headers'] = 'Content-Type'
return response
@osharim
osharim / Run django and nodejs running over nginx in the same server
Last active December 21, 2023 12:58
Nginx reverse proxy with Django & Node
#Django Config
server {
server_name domain.com;
access_log on;
location / {
proxy_pass http://127.0.0.1:8001;