Skip to content

Instantly share code, notes, and snippets.

View salmanwahed's full-sized avatar
🇧🇩
Bangladesh

Salman Wahed salmanwahed

🇧🇩
Bangladesh
View GitHub Profile
@salmanwahed
salmanwahed / apitest.py
Last active August 29, 2015 14:20
testing rest api
In [1]: from requests import get, post, put, delete
In [2]: get("http://127.0.0.1:5000/api")
In [3]: data = {"name": "Example Name", "registration": "123433199", "department": "cse"}
In [4]: post("http://127.0.0.1:5000/api", json=data).json()
In [5]: put("http://127.0.0.1:5000/api/123433199", json={"website": "www.example.com"}).json()
In [6]: delete("http://127.0.0.1:5000/api/123433199").json()
@salmanwahed
salmanwahed / api.py
Created May 1, 2015 15:23
REST Api with Flask-Restful and MongoDB
# -*- coding: utf-8 -*-
from flask import Flask, jsonify, url_for, redirect, request
from flask_pymongo import PyMongo
from flask_restful import Api, Resource
app = Flask(__name__)
app.config["MONGO_DBNAME"] = "students_db"
mongo = PyMongo(app, config_prefix='MONGO')
APP_URL = "http://127.0.0.1:5000"
@salmanwahed
salmanwahed / smwvimrc
Last active March 9, 2016 07:09
vimrc file
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" TODO: this may not be in the correct place. It is intended to allow overriding <Leader>.
" source ~/.vimrc.before if it exists.
if filereadable(expand("~/.vimrc.before"))
source ~/.vimrc.before
endif
class A(object):
def foo(self, x):
print "regular foo() method: %s %s" %(self, x)
@classmethod
def cls_foo(cls, x):
print "class method cls_foo(): %s %s" %(cls, x)