Exemple #1
0
def create_app():
    app = Flask(__name__)
    app.user = User()
    app.userList = UserList()
    app.usermap = UserLocationStore()
    app.friendStore = FriendStore()
    app.messageStore = MessageStore()
    app.userlocation = UserLocation()
    app.register_blueprint(site)
    app.register_blueprint(myMap)
    app.register_blueprint(register)
    app.register_blueprint(adminTable)
    app.register_blueprint(add)
    app.register_blueprint(add_doc)
    app.register_blueprint(image)
    app.register_blueprint(event)
    app.register_blueprint(notifications)
    app.store = Store()
    app.commentStore = CommentStore()
    app.requestStore = RequestStore()
    app.store_images = Store_Image()
    app.store_documents = Store_Document()
    app.register_blueprint(friends)
    app.register_blueprint(messages)
    app.register_blueprint(new)
    app.time = Timesql()
    app.init_db = init_db()
    app.savelocation = SaveLocation()
    app.notificationStore = NotificationStore()
    #    app.store.add_event(Event('World War II', date='15/12/1942', place='Turkey',content= 'Donec sed odio dui. Etiam porta sem malesuada magna mollis euismod. Nullam id dolor id nibh ultricies vehicula ut id elit'))
    #    app.store.add_event(Event('Train Accident', date='01/02/1985', place='California', content = 'Donec sed odio dui. Etiam porta sem malesuada magna mollis euismod. Nullam id dolor id nibh ultricies vehicula ut id elit'))
    return app
Exemple #2
0
def create_app():
    app = Flask(__name__)
    app.config.from_object('settings')
    app.register_blueprint(site)

    app.store = Store()
    app.store.add_shopping_list(Shopping_list(fullname='Ben Finkel', username='******', [email protected], password=ben_finkel,))
    app.store.add_shopping_list(Shopping_list(fullname='Alice Murray', username='******', [email protected], password=alice_murray))

    return app
Exemple #3
0
def create_app():
    app = Flask(__name__)
    app.secret_key = "secretkey"
    app.register_blueprint(site)
    app.userlist = UserList()
    app.blog = Blog()
    app.store = Store()
    app.library = Library()
    app.activitylist = ActivityList()
    return app
Exemple #4
0
import datetime
from flask import Flask
from flask import render_template

from movie import Movie
from store import Store

app = Flask(__name__)


@app.route('/')
def home_page():
    now = datetime.datetime.now()
    return render_template('home.html', current_time=now.ctime())


@app.route('/movies')
def movies_page():
    now = datetime.datetime.now()
    movies = app.store.get_movies()
    return render_template('movies.html',
                           movies=movies,
                           current_time=now.ctime())


if __name__ == '__main__':
    app.store = Store()
    app.store.add_movie(Movie('The Shining', year=1980))
    app.store.add_movie(Movie('Barton Fink', year=1991))
    app.run(host='0.0.0.0', port=5000)
Exemple #5
0
                        INSERT INTO MESSAGE(USERID, CLUBID, DATE, MSG, DIR, READ) VALUES (2, 1, '2017-10-22 18:00:00', 'etkinlige en gec kacta gelebiliriz ogrenebilir miyim?', true, false);
                        INSERT INTO MESSAGE(USERID, CLUBID, DATE, MSG, DIR, READ) VALUES (2, 1, '2017-10-22 19:00:00', 'oglen 12 de', false, false);
                        INSERT INTO MESSAGE(USERID, CLUBID, DATE, MSG, DIR, READ) VALUES (2, 2, '2017-10-22 19:00:00', 'selam', true, false);
                        INSERT INTO MESSAGE(USERID, CLUBID, DATE, MSG, DIR, READ) VALUES (2, 2, '2017-10-22 18:00:00', 'selam hocam', false, false);
                        """
        cursor.execute(query)
        connection.commit()

    flash("Database initialized.")

    return redirect(url_for('link1.home_page'))


if __name__ == '__main__':
    VCAP_APP_PORT = os.getenv('VCAP_APP_PORT')
    if VCAP_APP_PORT is not None:
        port, debug = int(VCAP_APP_PORT), False
    else:
        port, debug = 5000, True
    VCAP_SERVICES = os.getenv('VCAP_SERVICES')
    if VCAP_SERVICES is not None:
        app.config['dsn'] = get_elephantsql_dsn(VCAP_SERVICES)
    else:
        app.config['dsn'] = """user='******' password='******'
                               host='localhost' port=5432 dbname='itucsdb'"""

    REMEMBER_COOKIE_DURATION = timedelta(seconds=10)
    app.store = UserList(
        os.path.join(os.path.dirname(__file__), app.config['dsn']))
    app.run(host='0.0.0.0', debug=False)
Exemple #6
0
#! /usr/bin/env python2

from collections import OrderedDict
from flask import Flask, request, jsonify, json
import re
import argparse

app = Flask(__name__, static_url_path='/static')

# the database :)
app.store = dict()

#
# TODOS API: get / upsert / delete
#

# load all elements
@app.route("/api/todos", methods=["GET"])
def get_todos():
    ordered = sorted(app.store.values(), key=lambda v: v["order"])
    return json.dumps(ordered)

# updates an element or insert it if it doesn't exists
@app.route("/api/todos/<string:id>", methods=['PUT'])
def upsert_todo(id):
    # leaved here for readability, for performance compile outside this function
    regex_uuid = re.compile('[0-9a-f]{12}4[0-9a-f]{3}[89ab][0-9a-f]{15}\Z', re.I)
    if len(id) < 1 and not regex_uuid.match(id):
        return jsonify(result="fail", reason="invalid request: id")
    
    if id != request.json.get("id"):
Exemple #7
0
# We activate all log levels and prevent logs from showing twice.
app.logger.setLevel(logging.DEBUG)
app.logger.propagate = False

app.config.from_object(config)

CORS(
    app,
    allow_headers=["X-Requested-With"],
    allow_origin=app.config["ALLOW_ORIGIN"],
)

if "pytest" not in sys.modules:
    # Set up the redis store for tokens
    app.store = OAuthRedis(hex_key=app.config["SECRET_KEY"],
                           host=app.config["REDIS_HOST"])
    # We use the same store for sessions.
    session_store = PrefixDecorator("sessions_", RedisStore(app.store))
    KVSessionExtension(session_store, app)

url_prefix = app.config["SERVICE_PREFIX"]
blueprints = (
    gitlab_auth.blueprint,
    jupyterhub_auth.blueprint,
    web.blueprint,
)


@app.route("/", methods=["GET"])
def auth():
    if "auth" not in request.args:
Exemple #8
0
from flask import Flask
from flask_restful_swagger_2 import Resource, Api
from flask_cors import CORS
from endpoints import root, racks, rack, racksCloseBy
from datastore import Store

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

api.add_resource(root, '/<name>')
api.add_resource(racks, '/racks')
api.add_resource(rack, '/rack/<rackId>')
api.add_resource(racksCloseBy, '/racksCloseBy/<latitude>/<longitude>')

if __name__ == '__main__':
    app.store = Store('supportvelosigs.csv')
    app.run(debug=True, host='0.0.0.0')
Exemple #9
0
from flask import Flask, jsonify 

import os
import time
from xml.dom.minidom import parse

import datastore 

app = Flask(__name__)
app.debug = True
app.store = datastore.DataStore()
app.store.load("sdge.xml")

@app.route('/api/1.0/year/<int:year>')
def year_data(year): 
    data = app.store.get_year(year) 
    return jsonify(data)

@app.route('/api/1.0/year/<int:year>/month/<int:month>')
def year_month_data(year, month): 
    data = app.store.get_month(year, month) 
    return jsonify(data)

@app.route('/api/1.0/year/<int:year>/week/<int:week>')
def year_week_data(year, week): 
    data = app.store.get_week(year, week) 
    return jsonify(data)

@app.route('/api/1.0/year/<int:year>/day/<int:day>')
def year_day_data(year, day): 
    data = app.store.get_day(year, day) 
Exemple #10
0
import sys
import concurrent.futures
import pandas as pd
import datetime
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import encoders
from pymongo import MongoClient

app = Flask(__name__)
crontab = Crontab(app)

client = MongoClient("localhost")
app.store = client['Arctic_data']


# cron job to fetch the 1 minute result for all markets
# from the binance exchange and store them in redis cache for fast processing for higher intervals
@crontab.job()
@app.route('/get1m')
def process_1m_data():
    from flask import current_app as app
    count = 0

    def _fetch_result(symbol, store):
        t1 = time.time()
        ret = []
        data = binance.fetch_ohlcv(
            symbol, "1m", int((time.time() // 60 - 1) *
Exemple #11
0
#!/usr/bin/env python
from uuid import uuid4

from flask import Flask, abort, redirect, render_template, request
from redis.sentinel import Sentinel

app = Flask(__name__)
app.sentinel = Sentinel([('127.0.0.1', 26379)], socket_timeout=0.1)
app.store = app.sentinel.master_for('mymaster', socket_timeout=0.1)


def get_code():
    num = int(uuid4())
    alphabet = ("0123456789abcdefghijklmnopqrstuvwxyz"
                "ABCDEFGHIJKLMNOPQRSTUVWXYZ-_")
    if num == 0:
        return alphabet[0]
    arr = []
    base = len(alphabet)
    while num:
        num, rem = divmod(num, base)
        arr.append(alphabet[rem])
    arr.reverse()
    code = ''.join(arr)
    if app.store.get(code):
        return get_code()
    return code


def store_url(url):
    code = get_code()