This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import os, datetime, re | |
from flask import Flask, request, render_template, redirect, abort | |
from werkzeug import secure_filename | |
# import all of mongoengine | |
from flask.ext.mongoengine import mongoengine | |
# import data models | |
import models |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var filename = 'my_data_pic.png'; | |
var photoData = req.body.photoData; | |
// convert to buffer | |
var photo_buffer = new Buffer(b64str, 'base64'); | |
// prepare database record | |
var photoPost = new Photo(); // create Blog object | |
// pick the Amazon S3 Bucket |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route("/ideas/edit/<idea_id>", methods=['GET','POST']) | |
def idea_edit(idea_id): | |
if request.method == 'POST': | |
try: | |
idea = models.Idea.objects.get(id=request.form.get('idea_id')) | |
except: | |
abort(404) | |
# populate the IdeaForm with incoming form data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import os | |
# Retrieve Flask, our framework | |
# request module gives access to incoming request data | |
from flask import Flask, request | |
# create the Flask app | |
app = Flask(__name__) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import os | |
# Retrieve Flask, our framework | |
from flask import Flask | |
# create the Flask app | |
app = Flask(__name__) | |
# Main Page Route |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Flask related imports | |
from flask import Flask, render_template, jsonify, abort, request, make_response, session, redirect, url_for | |
# Flask extensions | |
from flask.ext.mongoengine import MongoEngine | |
from flask_debugtoolbar import DebugToolbarExtension | |
# Flask blueprints | |
import companies | |
from companies.views import companies |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var friendQuery = models.User.findById(userID); | |
friendQuery.exec(function(err, currentUser){ | |
// filter Users by _id using .friends id array | |
// $in operator in Mongo allows you to use an array as search param | |
// http://docs.mongodb.org/manual/reference/operator/#AdvancedQueries-%24in | |
// in mongoose http://mongoosejs.com/docs/api.html#query_Query-in | |
var filter = { _id : { $in : currentUser.friends } }; | |
// select the fields you want |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.new_photo = function(req, res){ | |
// Get File upload information | |
var filename = req.files.image.filename; // actual filename of file | |
var path = req.files.image.path; //will be put into a temp directory | |
var mimeType = req.files.image.type; // image/jpeg or actual mime type | |
// Create a new blog post | |
var photoPost = new Photo(); // create Blog object |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
/* IMPORTANT - must give map div height */ | |
#map-canvas { | |
height:400px; | |
} | |
/* IMPORTANT - fixes webkit infoWindow rendering */ | |
#map-canvas img { | |
max-width: none; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<label for="thenamebox"> | |
{{#errors.name}} | |
<span class="help-block alert alert-error">{{type}}</span> | |
{{/errors.name}} | |
Name <input type="text" name="name" id="thenamebox" value="{{astro.name}}" required> | |
</label> | |