Example #1
0
def create_app():
    app = Flask(__name__)
    app.debug = True
    app.config['SQLALCHEMY_DATABASE_URI'] = config.DB_URI
    app.config['ALLOWED_EXTENSIONS'] = set(['xls'])
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
    app.secret_key = 'songchao'

    bootstrap.init_app(app)
    db.init_app(app)
    return app
Example #2
0
from flask_ckeditor import CKEditor, upload_success, upload_fail
from flask_dropzone import Dropzone
from flask_wtf.csrf import validate_csrf
from wtforms import ValidationError

from forms import LoginForm, FortyTwoForm, NewPostForm, UploadForm, MultiUploadForm, SigninForm, \
    RegisterForm, SigninForm2, RegisterForm2, RichTextForm

app = Flask(__name__)
app.secret_key = os.getenv('SECRET_KEY', 'secret string')
app.jinja_env.trim_blocks = True
app.jinja_env.lstrip_blocks = True

# Custom config
app.config['UPLOAD_PATH'] = os.path.join(app.root_path, 'uploads')
app.config['ALLOWED_EXTENSIONS'] = ['png', 'jpg', 'jpeg', 'gif']

# Flask config
# set request body's max length
# app.config['MAX_CONTENT_LENGTH'] = 3 * 1024 * 1024  # 3Mb

# Flask-CKEditor config
app.config['CKEDITOR_SERVE_LOCAL'] = True
app.config['CKEDITOR_FILE_UPLOADER'] = 'upload_for_ckeditor'

# Flask-Dropzone config
app.config['DROPZONE_ALLOWED_FILE_TYPE'] = 'image'
app.config['DROPZONE_MAX_FILE_SIZE'] = 3
app.config['DROPZONE_MAX_FILES'] = 30

ckeditor = CKEditor(app)
Example #3
0
import json

#containernames = 'empty';

# Initialize the Flask application
app = Flask(__name__)

#Instantiating SwiftClient
swift = SwiftConnect()
#print(swift.containerList())
#swift.connectToSwift()

# This is the path to the upload directory
app.config['UPLOAD_FOLDER'] = 'uploads/'
# These are the extension that we are accepting to be uploaded
app.config['ALLOWED_EXTENSIONS'] = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif'])

#####################################################################################################################################################################################

# For a given file, return whether it's an allowed type or not
def allowed_file(filename):
    return '.' in filename and \
           filename.rsplit('.', 1)[1] in app.config['ALLOWED_EXTENSIONS']

#####################################################################################################################################################################################

# This route will show a form to perform an AJAX request
# jQuery is loaded to execute the request and update the
# value of the operation
@app.route('/')
def index():
Example #4
0
from PIL import Image                           # Image()
from resizeimage import resizeimage             # resize_width()
from werkzeug import secure_filename            # secure_filemane()
from flask_wtf import FlaskForm                 # FlaskForm
from flask_wtf.file import FileField            # FileField()
from flask_wtf.file import FileRequired         # FileRequired()
from wtforms.validators import ValidationError  # ValidationError()
import imghdr                                   # what()
import os                                       # join(), listdir()


app = Flask(__name__)

# App config
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024                         # 16Mb max per upload
app.config['ALLOWED_EXTENSIONS'] = ('bmp', 'gif', 'png', 'jpg', 'jpeg')     # Allowed file extensions to be uploaded
app.config['UPLOAD_DIR'] = 'uploads/'                                       # Upload directory
app.config['THUMBN_DIR'] = 'thumbnails/'                                    # Thumbnails directory
app.config['THUMBN_SIZE'] = [300, 300]                                      # Thumbnails size in px
app.secret_key = '1RK+3588rZaM081C/c6fhTIvNOzb1L9K9nP0ojX3O7b7wJjAz5/I7EICH3m+/530/sW7iotaUK4R'




# Custom validator
# Check that the file is a real image,
# Check that the file has a valid image extension
def validate_file(alwd_ext):

    def _validate_file(form, field):
Example #5
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

__author__ = 'Mike Fey (mike@mikefey.com)'
__license__ = 'MIT License'
__version__ = '0.1'

from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
from cmsapp.config import config

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = config.site_database_uri
app.config['UPLOAD_FOLDER'] = config.site_uploads_folder
app.config['ALLOWED_EXTENSIONS'] = \
    config.allowed_media_extensions
app.secret_key = config.site_secret_key
db = SQLAlchemy(app)

import cmsapp.views.admin.user
import cmsapp.views.admin.admin
import cmsapp.views.admin.media
import cmsapp.views.admin.page
import cmsapp.views.admin.category
import cmsapp.views.frontend.frontend

import cmsapp.models.site
import cmsapp.models.user
import cmsapp.models.media
import cmsapp.models.page
import cmsapp.models.productinfo
Example #6
0
from collections import defaultdict
import pandas as pd

#configuration and upload stuff 
app = Flask(__name__)
app.config.update(dict(
    DATABASE='bibtex.db',
    DEBUG=True,
    SECRET_KEY='development key',
    USERNAME='mb3152',
    PASSWORD='testing'))
app.config.from_envvar('FLASKR_SETTINGS', silent=True)
#path where uploaded files will go.
app.config['UPLOAD_FOLDER'] = 'uploads/'
# Only accept bibtex files
app.config['ALLOWED_EXTENSIONS'] = set(['bib'])
def allowed_file(filename):
    return '.' in filename and filename.rsplit('.', 1)[1] in app.config['ALLOWED_EXTENSIONS']

#start page
@app.route('/')
def index():
    return render_template('welcome2.html')

# upload the bibtex, store in database
@app.route('/upload', methods=['POST'])
def upload():
    file = request.files['file']
    collection = request.form['collection']
    if file and allowed_file(file.filename):
        filename = secure_filename(file.filename)
Example #7
0
from flask.ext.bootstrap import Bootstrap
from flask.ext.sqlalchemy import SQLAlchemy
from werkzeug import secure_filename
from flask.ext.wtf import Form
from wtforms import TextAreaField, SubmitField
from wtforms.validators import Required

# Sets the working path to be where the program is launched.
basedir = os.path.abspath(os.path.dirname(__file__))

# Creates an instance of the flask app
app = Flask(__name__)

# Sets where the uploads go and what file extensions may be uploaded
app.config['UPLOAD_FOLDER'] = 'static/upload/'
app.config['ALLOWED_EXTENSIONS'] = set(['jpg','png','bmp','jpeg','gif'])

# Points to the sql database
app.config['SQLALCHEMY_DATABASE_URI'] =\
'sqlite:///' + os.path.join(basedir, 'data.sqlite')
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True

# WTForms secret key for validation agains XSS attacks
app.config['SECRET_KEY'] = "The Night's Plutonian Shore"

# Create more instanses of things
db = SQLAlchemy(app)
bootstrap = Bootstrap(app)

# The database creation code
class CommentForm(Form):
Example #8
0
WTF_CSRF_ENABLED=False
SECRET_KEY="jkjlkjl"


app=Flask(__name__)
app.config.from_object(__name__)

app.config['SQLALCHEMY_DATABASE_URI']="sqlite:///"+os.path.join(os.path.dirname(__name__), "c3.db")
app.config['UPLOAD_FOLDER']=os.path.join(os.path.dirname(__name__), "uploads")
app.config['THREADS_PER_PAGE']=5
app.config['DEFAULT_NAME']="Anonymous"
app.config['THUMB_W']=200
app.config['THUMB_H']=200
app.config['ALLOWED_FILETYPES']=['png', 'jpeg']
app.config['ALLOWED_EXTENSIONS']=['.png', '.jpg']
app.config['PREVIEW_POSTS']=5
app.config['PREVIEW_LINES']=15

db=SQLAlchemy(app)
login_manager=LoginManager()
login_manager.init_app(app)

#######################
#######################
class ChangePasswordForm(Form):
	oldpassword=PasswordField('oldpassword')
	password=PasswordField('password')
	password2=PasswordField('password2')
class LoginForm(Form):
	name=TextField('name')
Example #9
0
from sqlalchemy.sql import exists
from sqlalchemy.orm import sessionmaker, scoped_session
import datetime, os
import psutil
from sqlalchemy import create_engine
#import iptc

app = Flask(__name__)
### mysql://username:password@serverhost/databasename
app.config["SQLALCHEMY_DATABASE_URI"] = "mysql://sql8128062:xW9TErGiJF@sql8.freemysqlhosting.net/sql8128062"

app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
#app.config['SQLALCHEMY_POOL_SIZE'] = 100
app.config["SQLALCHEMY_POOL_RECYCLE"] = 7200

app.config['ALLOWED_EXTENSIONS'] = set(['csv'])

db = SQLAlchemy(app)

#some_engine = create_engine("mysql://sql8128062:xW9TErGiJF@sql8.freemysqlhosting.net/sql8128062", pool_recycle=280)


# create a configured "Session" class
#Session = sessionmaker(bind=some_engine)

# create a Session
#session = Session()

    

class Users(db.Model):
Example #10
0
import os
from flask import Flask, request, redirect, url_for, send_from_directory
from flask_restful import Resource, Api, reqparse
from sqlalchemy import create_engine
from werkzeug import secure_filename
from werkzeug.datastructures import FileStorage

app = Flask(__name__)
api = Api(app)

# Configs
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///malware.db'
app.config['UPLOAD_FOLDER'] = 'uploads'
app.config['DOWNLOAD_FOLDER'] = 'samples'
app.config['ALLOWED_EXTENSIONS'] = set(['zip'])

# SQLite engine, db assumed to be in same directory
e = create_engine(app.config['SQLALCHEMY_DATABASE_URI'])
ALLOWED_EXTENSIONS = set(['zip'])


###############################################################################
####### DB Functions
###############################################################################

def get_current_sample_id(machine_id):
    '''
       Returns the malware sample id, or
       None if the machine doesn't exist in db
     '''
    malware_id = None
Example #11
0
# using the request object from flask. Redirect and url_for
# will be used to redirect the user once the upload is done
# and send_from_directory will help us to send/show on the
# browser the file that the user just uploaded
from flask import Flask, render_template, request, redirect, url_for, send_from_directory
from werkzeug.utils import secure_filename
import random

# Initialize the Flask application
app = Flask(__name__)

# This is the path to the upload directory
app.config['UPLOAD_FOLDER'] = 'uploads/'
app.config['DOWNLOAD_FOLDER'] = 'downloads/'
# These are the extension that we are accepting to be uploaded
app.config['ALLOWED_EXTENSIONS'] = {['conf', 'rules']}


# For a given file, return whether it's an allowed type or not
def allowed_file(filename):
    return '.' in filename and \
           filename.rsplit('.', 1)[1] in app.config['ALLOWED_EXTENSIONS']


# This route will show a form to perform an AJAX request
# jQuery is loaded to execute the request and update the
# value of the operation
@app.route('/')
def index():
    return render_template('index.html')
Example #12
0
CloudMoss - Check against moss in the cloud.
'''

from flask import Flask, render_template, request, redirect, abort
from werkzeug import secure_filename

import os
import datetime
import moss
import zipfile
import requests

#Application Setup
app = Flask(__name__)
app.config['UPLOAD_DIR'] = 'uploads'
app.config['ALLOWED_EXTENSIONS'] = set(['zip']) #Support for other file types coming soon.
app.config['SUPPORTED_LANGUAGES'] = set(['java', 'python'])

#Helper methods
def valid_file(filename):
    return '.' in filename and filename.rsplit('.', 1)[1] in app.config['ALLOWED_EXTENSIONS']

def filetype(filename):
    return filename.rsplit('.', 1)[1]


#Controllers
@app.route('/', methods=['GET', 'POST'])
@app.route('/<language>', methods=['GET', 'POST'])
def upload(language='python'):
    if language not in app.config['SUPPORTED_LANGUAGES']:
Example #13
0
# 載入platform模組,可以用來獲取系統訊息
import platform
import logging
from logging.handlers import RotatingFileHandler
# raise ImportError('Try "python setup.py install" or "pip install -r requirements.txt"')


flaskApplication = Flask(__name__, static_url_path = "", static_folder = "static/", template_folder = 'templates/')
flaskApplication.debug = False
flaskApplication.config['FOLDER'] = os.getcwd()
flaskApplication.config['VIDEO_FOLDER'] = "file/video/"
flaskApplication.config['VIDEO_THUMBNAIL_FOLDER'] = "/file/image/streamshot/"
flaskApplication.config['ALLOWED_EXTENSIONS'] = set([
    # "txt",
    # "pdf",
    # "png", "jpg", "jpeg", "gif",
    # "db",
    "mp3",
    "mp4", "webm", "ogg"
])
flaskApplication.config['PORT'] = 8000
flaskApplication.config['NGINX_FOLDER'] = 'nginx-1.10.1'
flaskApplication.config['NGINX_PORT'] = 80
flaskApplication.config['DATABASE_FILE'] = 'database.db'
flaskApplication.config["SECRET_KEY"] = "0" * 24 # binascii.hexlify(os.urandom(24))
flaskApplication.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + flaskApplication.config['DATABASE_FILE']
flaskApplication.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
socketio = SocketIO(flaskApplication, async_mode = "eventlet", ping_timeout = 20, ping_interval = 0, binary = True) # , ping_timeout = 30, ping_interval = 30, binary = True
sqlAlchemy = SQLAlchemy(flaskApplication)
login_manager = LoginManager()
colorama.init()
connection = {}
Example #14
0
import os
from flask import Flask, request, redirect, url_for
from flask import *
from OHDocumentConversion import *
import requests

app = Flask(__name__)
UPLOAD_FOLDER = 'data'

app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
app.config['ALLOWED_EXTENSIONS'] = set(['txt', 'pdf', 'html'])

def allowed_file(filename):
    return '.' in filename and filename.rsplit('.', 1)[1] in app.config['ALLOWED_EXTENSIONS']

@app.route('/')
def main():
    return render_template('index.html')

@app.route('/upload')
def upload():
    return render_template('upload.html')

@app.route('/uploaded')
def uploaded():
    return render_template('uploaded.html')

@app.route('/magic', methods=["POST"])
def results():
   file = request.files['file']
   if file and allowed_file(file.filename):
Example #15
0
            return redirect(url_for('signup'))
        flash("Great! You've registered! Now you can log in.")
        return redirect(url_for('login'))
    return render_template("signup.html")


@app.route('/studyguides',methods=['GET','POST'])
def guides():
    return render_template('classes.html')

@app.route('/studyguides/<classname>')
def showClassGuides():
    return render_template('classguides.html',classname=classname)



app.config['UPLOAD_FOLDER'] = 'uploads/'
app.config['ALLOWED_EXTENSIONS'] = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif', 'doc', 'docx', 'odt', 'ppt'])

def allowed_file(filename):
    return '.' in filename and \
           filename.rsplit('.', 1)[1] in app.config['ALLOWED_EXTENSIONS']    

@app.route('/uploads/<filename>')
def uploaded_file(filename):
    return send_from_directory(app.config['UPLOAD_FOLDER'],
                               filename)

if __name__ == '__main__':
    app.run(debug=True)
Example #16
0
from flask import Flask, render_template, request, json
from werkzeug.utils import secure_filename
import diff_match_patch
import re
import os, codecs
import sys

sys.path.append("..")
import logdiffutil

app = Flask(__name__)

# This is the path to the upload directory
UPLOAD_FOLDER = 'compfiles'
# These are the extension that we are accepting to be uploaded
app.config['ALLOWED_EXTENSIONS'] = set(['txt', 'log', 'cfg','arti', 'out'])

# For a given file, return whether it's an allowed type or not
def allowed_file(filename):
    return '.' in filename and \
           filename.rsplit('.', 1)[1] in app.config['ALLOWED_EXTENSIONS']

@app.route("/")
def main():
    return render_template("main.html")

# Get diff log output
@app.route("/getFileDiffResults", methods = ['POST'])
def getFileDiffResults():
    try:
        file1 = request.files['file1']
Example #17
0
from flask import Flask, request, send_from_directory, redirect, url_for, render_template, Response
from werkzeug.utils import secure_filename
from functools import wraps
import tinys3
import random, os, config, uuid, time, models, database

#Setup
application = Flask(__name__)
s3_connection = tinys3.Connection(config.aws_access_key, config.aws_secret_key, tls=True, endpoint=config.aws_s3_endpoint)


#Load Configuration Variables
application.config['ALLOWED_EXTENSIONS'] = config.file_extentions
application.config['UPLOAD_DIRECTORY'] = config.upload_directory
application.config['URL_LENGTH'] = config.default_url_length
application.config['ALPHA_CHARS'] = config.url_characters
application.config['PATH'] = config.app_path
application.config['USER'] = config.app_username
application.config['PASSWORD'] = config.app_password

#Create the temporary directory to save images
if not os.path.exists(application.config['UPLOAD_DIRECTORY']):
    os.mkdir(application.config['UPLOAD_DIRECTORY'])


#App Methods
def strip_extenstion(filename: str) -> str:
    '''
    Strips the file extension from a file
    :param filename: A filename, such as 'example.txt'
    :return: A string of the extension type, such as 'txt', or None if there is no extension
Example #18
0
    db.set('SERVER_NAME', 'localhost');

if not db.get('SOCKET_PORT'):
    db.set('SOCKET_PORT', 5001);

if not db.get('UPLOAD_FOLDER'):
    db.set('UPLOAD_FOLDER', '/var/www/yeti-cam/uploads');

if not db.get('CAM_LOG_FOLDER'):
    db.set('CAM_LOG_FOLDER', '/var/www/yeti-cam/logs');

if not db.get('ALLOWED_EXTENSIONS'):
    db.set('ALLOWED_EXTENSIONS', ['jpg', 'jpeg', 'txt', 'h264'])

if not db.get(constants.GDRIVE_FOLDER):
    db.set(constants.GDRIVE_FOLDER, '')

if not db.get(constants.ENABLE_GDRIVE):
    db.set(constants.ENABLE_GDRIVE, False)

if not db.get(constants.STATUS):
    db.dcreate(constants.STATUS)

if not db.get(constants.LAST_CAM_UPDATE):
    db.set(constants.LAST_CAM_UPDATE, datetime.datetime.now().isoformat())

app.config['UPLOAD_FOLDER'] = db.get('UPLOAD_FOLDER')
app.config['CAM_LOG_FOLDER'] = db.get('CAM_LOG_FOLDER')
app.config['ALLOWED_EXTENSIONS'] = db.get('ALLOWED_EXTENSIONS')
app.config['SOCKET_PORT'] = db.get('SOCKET_PORT')
app.config['SECRET_KEY'] = 'secret!'
Example #19
0
import os, shutil, sys
from flask import Flask, request, render_template, jsonify, send_from_directory
from flask.ext.assets import Environment, Bundle
from werkzeug import secure_filename
from snipper import *
import file_helpers

# TODO: refactor this goddamn thing

app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = file_helpers.UPLOAD_FOLDER
app.config['TMP_FOLDER'] = file_helpers.TMP_FOLDER
app.config['ALLOWED_EXTENSIONS'] = file_helpers.ALLOWED_EXTENSIONS
app.config['MAX_CONTENT_LENGTH'] = 20 * 1024 * 1024

# assets
assets = Environment(app)
js = Bundle('vendor/js/jquery-1.7.2.min.js',
	'vendor/js/jquery-ui-1.8.21.custom.min.js',
	'vendor/js/jquery.iframe-transport.js',
	'vendor/js/jquery.fileupload.js',
  'vendor/js/underscore.js',
  'vendor/js/backbone.js',
    filters='rjsmin', output='gen/packed.js')

coffee = Bundle('assets/js/*.coffee',
    filters="coffeescript", output="gen/application.js")

sass = Bundle('assets/css/*.sass',
	filters="sass", output="gen/application.css")
Example #20
0
from flask import Flask, render_template, request, redirect, url_for, send_from_directory
from werkzeug import secure_filename
import pygraphviz as pgv
import graph as test
import time

reload(sys)
sys.setdefaultencoding("utf-8")

CURRENT_DIRECTORY = os.getcwd()
BUCKET_NAME = "temp_folder/"  # directory to store files
BUCKET_PATH = os.path.join(CURRENT_DIRECTORY, BUCKET_NAME)

app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = BUCKET_PATH
app.config['ALLOWED_EXTENSIONS'] = set(['pml'])


def __init__():
    if not os.path.exists('temp_folder'):
        os.mkdir('temp_folder')


@app.route('/')
def main():
    __init__()

    return render_template('graph.html')


# For a given file, return whether it's an allowed type or not
Example #21
0
import os, io
import random
import numpy as np
from scipy import interpolate
from flask import Flask, request, jsonify, send_file, abort, render_template
from werkzeug import secure_filename
import functions

app = Flask(__name__)

app.config['ALLOWED_EXTENSIONS'] = set(['txt'])
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16 MB

def allowed_file(filename):
    return '.' in filename and \
           filename.rsplit('.', 1)[1] in app.config['ALLOWED_EXTENSIONS']

@app.route("/")
def hello():
     return render_template('index.php')

@app.route("/analyse", methods=['POST'])
def analyse():
    data = request.files.get('file', '')
    if data:
        filename = secure_filename(data.filename)
        in_memory_file = io.BytesIO()
        data.save(in_memory_file)
        data = np.fromstring(in_memory_file.getvalue(), dtype=np.uint8)
        text = ''.join(chr(i) for i in data)
        value = []
Example #22
0
application = Flask(__name__)
application.config.from_object(__name__)

# FlaskDB is a wrapper for a peewee database that sets up pre/post-request
# hooks for managing database connections.
flask_db = FlaskDB(application)

# The `database` is the actual peewee database, as opposed to flask_db which is
# the wrapper.
database = flask_db.database

# Upload folder and file allowed extensions
if os.getenv('SANDSTORM'):
    application.config['UPLOAD_FOLDER'] = '/var/uploads'
    application.config['PREFERRED_URL_SCHEME'] = 'https'
    application.config['DEBUG'] = False
else:
    application.config['UPLOAD_FOLDER'] = '%s/uploads' % os.path.join(APP_DIR)
    application.config['DEBUG'] = True

# file types allowed for upload
application.config['ALLOWED_EXTENSIONS'] = set(['jpg', 'jpeg', 'png', 'gif', 'webp'])

# This is used by micawber, which will attempt to generate rich media
# embedded objects with maxwidth=800.
application.config['SITE_WIDTH'] = 800

# The secret key is used internally by Flask to encrypt session data stored
# in cookies. Make this unique for your app.
application.config['SECRET_KEY'] = 'asdfkj23kjdflkj23lkjs'
Example #23
0
from flask import Flask
import sys
from reports.publications.articles import report_per_year as report_year_articles
from reports.publications.videos import  report_per_year as report_year_videos
from reports.top_owner import report_per_period as report_top_owner
from reports.number_views import  report_per_period as report_number_views
from reports.infographic_publications import  report_per_period as report_infographic_publications
from reports.top_report import report_per_period as report_top
from reports.factor_report import report_per_period as report_factors
from max_dev import root_path

from uploadExcel import upload_api

app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = 'uploads/'
app.config['ALLOWED_EXTENSIONS'] = set(['xlsx', 'xlsm'])
app.register_blueprint(upload_api)

root_path.set_root_path_from(__file__)

@app.route('/')
def home():
    return app.send_static_file('selector_report.html')


@app.route('/<path:path>')
def selector(path):
    print path
    return app.send_static_file(path)

import subprocess
# We'll render HTML templates and access data sent by POST
# using the request object from flask. Redirect and url_for
# will be used to redirect the user once the upload is done
# and send_from_directory will help us to send/show on the
# browser the file that the user just uploaded
from flask import Flask, render_template, request, redirect, url_for, send_from_directory
from werkzeug import secure_filename

# Initialize the Flask application
app = Flask(__name__)

# This is the path to the upload directory
app.config['UPLOAD_FOLDER'] = 'uploads/'
# These are the extension that we are accepting to be uploaded
app.config['ALLOWED_EXTENSIONS'] = set(['apk'])

# For a given file, return whether it's an allowed type or not
def allowed_file(filename):
    return '.' in filename and \
           filename.rsplit('.', 1)[1] in app.config['ALLOWED_EXTENSIONS']

# This route will show a form to perform an AJAX request
# jQuery is loaded to execute the request and update the
# value of the operation
@app.route('/')
def index():
    return render_template('index.html')


# Route that will process the file upload
Example #25
0
from flask import Flask,render_template, request, redirect, url_for, send_from_directory, send_file
from werkzeug import secure_filename
import sys
import os
import subprocess 
import time
import glob

app = Flask(__name__)

app.config['UPLOAD_FOLDER'] = 'images/'
app.config['ALLOWED_EXTENSIONS'] = set(['png', 'jpg', 'JPG', 'PNG'])

#thanks for the help http://code.runnable.com/UiPcaBXaxGNYAAAL/how-to-upload-a-file-to-the-server-in-flask-for-python
def allowed_file(filename):
    return '.' in filename and \
           filename.rsplit('.', 1)[1] in app.config['ALLOWED_EXTENSIONS']

@app.route('/images/wallpapers/<filename>')
def render_image(filename):
	return send_file('images/wallpapers/' + filename, mimetype='image/jpg')

@app.route('/')
def index():
	return render_template('index.html')

@app.route('/upload', methods=['POST'])
def upload_file():
	file = request.files['file']
	if file and allowed_file(file.filename):
Example #26
0
from flask_oauth_c import OAuth
from blitzdb import FileBackend
from objects import Waifu, User
from vote import votes
from config import _cfg, _cfgi
from flask.ext.login import login_user, LoginManager, current_user, logout_user
import requests
import re

import random

app = Flask(__name__)
app.register_blueprint(votes)
app.dbbackend = FileBackend("./database")
app.config['UPLOAD_FOLDER'] = _cfg("content-folder")
app.config['ALLOWED_EXTENSIONS'] = set(['png', 'jpg', 'jpeg', 'gif', 'JPEG', 'JPG', 'PNG', 'GIF'])


login_manager = LoginManager()
login_manager.init_app(app)

app.config['WAIFU_BGS'] = list(["0.png","1.png"])

oauth = OAuth()

google = oauth.remote_app('google',
                          base_url='https://www.google.com/accounts/',
                          authorize_url='https://accounts.google.com/o/oauth2/auth',
                          request_token_url=None,
                          request_token_params={'scope': 'https://www.googleapis.com/auth/userinfo.email',
                                                'response_type': 'code'},
Example #27
0
from flask import Flask

from service_config import UPLOAD_FOLDER, ALLOWED_EXTENSIONS

app = Flask(__name__)
app.config['ALLOWED_EXTENSIONS'] = ALLOWED_EXTENSIONS
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
from app import views
Example #28
0
# will be used to redirect the user once the upload is done
# and send_from_directory will help us to send/show on the
# browser the file that the user just uploaded
from flask import Flask, render_template, request, redirect, url_for, send_from_directory
from werkzeug import secure_filename
from werkzeug.contrib.fixers import ProxyFix

# Initialize the Flask application
app = Flask(__name__)

app.wsgi_app = ProxyFix(app.wsgi_app)

# This is the path to the upload directory
app.config['UPLOAD_FOLDER'] = 'server/data/replays/'
# These are the extension that we are accepting to be uploaded
app.config['ALLOWED_EXTENSIONS'] = set(['dem'])

# For a given file, return whether it's an allowed type or not
def allowed_file(filename):
    return '.' in filename and \
           filename.rsplit('.', 1)[1] in app.config['ALLOWED_EXTENSIONS']

# Route that will process the file upload
@app.route('/upload', methods=['POST'])
def upload():
    print "got request"
    # Get the name of the uploaded file
    file = request.files['file']
    # Check if the file is one of the allowed types/extensions
    if file and allowed_file(file.filename):
        # Make the filename safe, remove unsupported chars
Example #29
0
import os
import json
import logging
from flask import Flask, render_template, request, redirect, url_for, send_from_directory
from werkzeug import secure_filename
from logging.handlers import RotatingFileHandler

import pyspark
sc = pyspark.SparkContext()
# Initialize the Flask application
app = Flask(__name__)

# This is the path to the upload directory
app.config['UPLOAD_FOLDER'] = 'uploads/'

app.config['ALLOWED_EXTENSIONS'] = set(['txt', 'pdf','PROJECT'])

filename = "log1000-1.txt"
# For a given file, return whether it's an allowed type or not
def allowed_file(filename):
    return '.' in filename and \
           filename.rsplit('.', 1)[1] in app.config['ALLOWED_EXTENSIONS']
           

@app.route('/layout')
def layout():
    return render_template('layout.html')

@app.route('/')
def index():
    rdd = sc.parallelize(['Hello','World'])
from flask import session as login_session
import random, string, itertools
from oauth2client.client import flow_from_clientsecrets
from oauth2client.client import FlowExchangeError
import httplib2
import json
from flask import make_response
import requests



app = Flask(__name__)

# App configuration intended for image uploads
app.config['UPLOAD_FOLDER'] = 'static/images/models/'
app.config['ALLOWED_EXTENSIONS'] = set(['jpg', 'jpeg'])

# For a given file for upload, return whether it's an allowed type or not
def allowed_file(filename):
    return '.' in filename and filename.rsplit('.', 1)[1] in app.config['ALLOWED_EXTENSIONS']


CLIENT_ID = json.loads(
    open('client_secrets.json', 'r').read())['web']['client_id']
APPLICATION_NAME = "Luxury Rides App"



#Connect to Database and create database session
engine = create_engine('sqlite:///luxuryridescatalog.db')
Base.metadata.bind = engine