Got tired of using curl. I switched to httpie. 1. Install $ pip3 install httpie 2. I use jwt $ pip3 install -U httpie-jwt-auth 3. First get token $ http POST :8001/api-token-auth/ 'username=admin' 'password=abc123' 4. Now set env variables $ export JWT_AUTH_TOKEN=your_token $ export JWT_AUTH_PREFIX=JWT 5. Now do whatever $ http --auth-type=jwt :8001/users/ 6. If this error is encountered... SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed Use --verify=no as in... $ http --verify=no POST ...
8.23.2017
Use httpie to play with your APIs
8.17.2017
Django LDAP Logging
Got from here Add in settings.py import logging, logging.handlers logfile = "/tmp/django-ldap-debug.log" my_logger = logging.getLogger('django_auth_ldap') my_logger.setLevel(logging.DEBUG) handler = logging.handlers.RotatingFileHandler( logfile, maxBytes=1024 * 500, backupCount=5) formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') handler.setFormatter(formatter) my_logger.addHandler(handler)
8.10.2017
Angular Starter Project with Material
Follow angular setup from this post. Reference posts from here and here. And from a starter project. 1. Create angular project $ ng new management-gui $ cd management-gui 2. Get Angular Material $ yarn add @angular/material @angular/animations @angular/cdk 3. Get HammerJs and add to .angular-cli.json $ yarn add hammerjs $ vi .angular-cli.json "scripts": [ "../node_modules/hammerjs/hammer.min.js" ], 4. Add Angular Material on to app.module.ts $ vi src/app/app.module.ts import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { HttpModule } from '@angular/http'; import { MaterialModule } from '@angular/material'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import 'hammerjs'; import { AppComponent } from './app.component'; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, FormsModule, HttpModule, MaterialModule, BrowserAnimationsModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { } 5. Set global styles.css with an Angular Material theme $ vi src/styles.css @import '~@angular/material/prebuilt-themes/indigo-pink.css'; 6. Add Material icons in index.html $ vi src/index.html
8.09.2017
Django Development Production Settings
I choose the 2nd solution from this post Dir structure: [myapp]$ tree . ├── __init__.py ├── settings │ ├── __init__.py │ ├── defaults.py │ ├── development.py │ ├── production.py │ └── staging.py ### __init.py__ from myapp.settings.development import * ### defaults.py ### sensible choices for default settings ### dev.py from myapp.settings.defaults import * DEBUG = True ### other development-specific stuff ### production.py from myapp.settings.defaults import * DEBUG = False ### other production-specific stuff ### staging.py from myapp.settings.defaults import * DEBUG = True ### other staging-specific stuff
Subscribe to:
Posts (Atom)