Skip to content

Instantly share code, notes, and snippets.

#news handler, pulls news from mongodb, renders news page
class NewsHandler (tornado.web.RequestHandler):
def get(self, currentPage):
news_content = dict()
coll = self.application.db.news
news = coll.find().sort("_id", DESCENDING)
#pagination code
currentPage = int(currentPage)
newsItemsPerPage = 2
@BrajeshKhare
BrajeshKhare / payoneer.php
Created May 23, 2016 10:51 — forked from pmoust/payoneer.php
payoneer.php
<?php
/**
* Payoneer API integration
*
* @date 27/11/12
* @name $payoneer
* @author Panagiotis Moustafellos
*/
class Payoneer
{
@BrajeshKhare
BrajeshKhare / application
Created May 19, 2016 09:40 — forked from ryancutter/application
Simple Python/Tornado web server tailored for hosting on OpenShift (https://openshift.redhat.com)
#!/usr/bin/python
import os
virtenv = os.environ['APPDIR'] + '/virtenv/'
os.environ['PYTHON_EGG_CACHE'] = os.path.join(virtenv, 'lib/python2.6/site-packages')
virtualenv = os.path.join(virtenv, 'bin/activate_this.py')
try:
execfile(virtualenv, dict(__file__=virtualenv))
except IOError:
pass
@BrajeshKhare
BrajeshKhare / login.html
Created May 13, 2016 07:30 — forked from guillaumevincent/login.html
Basic authentication on Tornado with a decorator
<div id="main-container">
<div id="main">
<h1>
<img alt="scubabook logo" src="{{ static_url("img/logo.png") }}">
</h1>
<div id="login-form">
<form action="/auth/login/" method="post" id="login_form">
<fieldset>
<label for="username">Username</label>
<input autocapitalize="off" autocorrect="off" class="text-input" id="username" name="username" tabindex="1" type="text" value="">
@BrajeshKhare
BrajeshKhare / model-tests-in-tornado.py
Created May 9, 2016 08:51 — forked from didip/model-tests-in-tornado.py
Example on how to tests your model classes in Tornado
import unittest, os, os.path, sys
import tornado.database
import tornado.options
from tornado.options import options
APP_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
sys.path.append(os.path.join(APP_ROOT, '..'))
# import your model module
import your.model as model