예제 #1
0
 def setUp(self):
     app.config['TESTING'] = True
     app.config['WTF_CSRF_ENABLED'] = False
     app.config['DEBUG'] = False
     app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.abspath('test.db')
     self.app = app.test_client()
     app.register_blueprint(animal_api)
     db.drop_all()
     db.create_all()
예제 #2
0
파일: app.py 프로젝트: comprodb/cs373-idb
from blueprints.users import users
from blueprints.test import test
from blueprints.search import search
from config import SQLALCHEMY_DATABASE_URI, DEBUG_DATABASE_URI
from flask import jsonify, request
from models import app, db

import json
import models
import psycopg2
import requests
import sys
import time
import os.path

app.register_blueprint(contests, url_prefix='/api/contests')
app.register_blueprint(problems, url_prefix='/api/problems')
app.register_blueprint(users, url_prefix='/api/users')
app.register_blueprint(test, url_prefix='/api/test')
app.register_blueprint(search, url_prefix='/api/search')

@app.route('/api/meteors')
def meteors():
    response = jsonify(data=json.loads(requests.get('http://meteorite-landings.me/api/meteorites').text))
    return response

# Routes
@app.route('/')
def root():
    # Send default home page
    return app.send_static_file("index.html")
예제 #3
0
파일: main.py 프로젝트: noiffion/hamnet
import os
import json
import random
import string
import datetime
from flask_sqlalchemy import SQLAlchemy
from flask_login import login_required, login_user, current_user, logout_user
from models import db, login_manager, app
from oauth import blueprint
from models import (Genres, Plays, User, Reviews, OAuth, Cities, Theatres, 
                    Performances, db, login_manager, app)
from flask import (Flask, render_template, redirect, jsonify, url_for, flash,
                   request as flask_req, session as login_session)

app.register_blueprint(blueprint, url_prefix="/login")
login_manager.init_app(app)


@app.route("/logout")
@login_required
def logout():
    logout_user()
    flash("You have logged out")
    return redirect(url_for("home"))


@app.route("/login/facebook/authorized")
def authorized():
    current_uri = login_session.get('current_uri')
    print("\nauthorized current_uri: ", current_uri, "\n")
    return redirect(url_for(current_uri))
예제 #4
0
파일: app.py 프로젝트: tintinthong/shopyo
from flask import (Flask, redirect, url_for, render_template)
from models import app

from views.manufac import manufac_blueprint
from views.products import prod_blueprint
from views.people import person_blueprint
from views.settings_modif import settings_blueprint
{{IMPORTS}}

app.register_blueprint(manufac_blueprint)
app.register_blueprint(prod_blueprint)
app.register_blueprint(person_blueprint)
app.register_blueprint(settings_blueprint)
{{REGISTER_BLUEPRINTS}}


@app.route('/')
def index():
    return redirect('/manufac/')


if __name__ == '__main__':
    app.run(debug=True, host='127.0.0.1')
예제 #5
0
from models import app
from stock import main as stock_routes

# 注册蓝图
app.register_blueprint(stock_routes, url_prefix='/stock')

# 运行代码
# 默认端口是 5000
if __name__ == '__main__':
    app.run(debug=True)
예제 #6
0
from models import Clients, ClientLog, app, db, VaccControl, Vaccines, ForeignCountries, PresenceIn, Hospitals
import datetime
from random import randint

main = Blueprint('main', __name__)
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
app.config['SECRET_KEY'] = '9OLWxND4o83j4K4iuopO'

# host = os.environ.get('DB_HOST', 'localhost')
# app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://{user}:{password}@{host}/{database}'.format(
#     user='******', password='******', database='vakcina', host=host)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///vaccina.db'

app.config['JSON_AS_ASCII'] = False

app.register_blueprint(app_db)

db.init_app(app)
login_manager = LoginManager()
login_manager.login_view = 'auth.login'
login_manager.login_message = "Щоб продовжити роботу необхідно увійти"
login_manager.init_app(app)
app.url_map.strict_slashes = False

blueprint = Blueprint("", __name__)


@main.route("/")
@login_required
def index():
예제 #7
0
from wtforms import ValidationError

from admin import NewAdminView, NewModelView, NewFileAdmin
from cli import create_db
from config import Config
from models import app, db, Register, login_manager, Users, Menu, Cart, OrderSummary
from oauth import google, twitter
from sendMail import send_mail, send_approval_mail

# flask migration connecting the app and the database
Migrate(app, db)

# configuring the app
app.config.from_object(Config)
app.cli.add_command(create_db)
app.register_blueprint(google.blueprint, url_prefix="/login")
app.register_blueprint(twitter.blueprint, url_prefix="/login")
db.init_app(app)
login_manager.init_app(app)

# Upload Photos
photos = UploadSet('photos', IMAGES)
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg'}
app.config['UPLOADED_PHOTOS_DEST'] = 'static/pictures'
configure_uploads(app, photos)

# Admin
admin = Admin(app,
              index_view=NewAdminView(),
              name='maytrixCafe',
              template_mode='bootstrap3')
예제 #8
0
from flask import Flask
from todo import main as todo_routes
from api import main as api_routes
from models import app

# app = Flask(__name__)
# app.secret_key = 'random string'
# app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True

app.register_blueprint(todo_routes)
app.register_blueprint(api_routes, url_prefix='/api')

if __name__ == '__main__':
    config = dict(
        debug=True,
        host='0.0.0.0',
        port=2000,
    )
    app.run(**config)
예제 #9
0
from blueprints.users import users
from blueprints.test import test
from blueprints.search import search
from config import SQLALCHEMY_DATABASE_URI, DEBUG_DATABASE_URI
from flask import jsonify, request
from models import app, db

import json
import models
import psycopg2
import requests
import sys
import time
import os.path

app.register_blueprint(contests, url_prefix='/api/contests')
app.register_blueprint(problems, url_prefix='/api/problems')
app.register_blueprint(users, url_prefix='/api/users')
app.register_blueprint(test, url_prefix='/api/test')
app.register_blueprint(search, url_prefix='/api/search')


@app.route('/api/meteors')
def meteors():
    response = jsonify(data=json.loads(
        requests.get('http://meteorite-landings.me/api/meteorites').text))
    return response


# Routes
@app.route('/')
예제 #10
0
파일: main.py 프로젝트: lvconl/python-blog
from ajax import ajax
from models import app

views = __import__('views')
app.register_blueprint(ajax)

if __name__ == '__main__':
    app.run()
예제 #11
0
import uuid
import re
import string
from random import choices
from ip2geotools.databases.noncommercial import DbIpCity
import pycountry
import json
from collections import Counter

# flask migration connecting the app and the database
Migrate(app, db)

# configuring the app
app.config.from_object(Config)
app.cli.add_command(create_db)
app.register_blueprint(google.blueprint, url_prefix="/login")
app.register_blueprint(twitter.blueprint, url_prefix="/login")
app.register_blueprint(facebook.blueprint, url_prefix="/login")
app.register_blueprint(github.blueprint, url_prefix="/login")
db.init_app(app)
login_manager.init_app(app)

# enabling insecure login for OAuth login
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'
os.environ['OAUTHLIB_RELAX_TOKEN_SCOPE'] = '1'


# Views
# Home page
@app.route("/")
def index():
예제 #12
0
from ajax import ajax
from models import app
from models import db
from topic.views import topic
from comment.views import comment
from user.views import person
from answer.views import answer
from admin.views import admin

views = __import__('views')
app.register_blueprint(ajax)
app.register_blueprint(topic)
app.register_blueprint(comment)
app.register_blueprint(person)
app.register_blueprint(answer)
app.register_blueprint(admin)

if __name__ == '__main__':
    app.run()
예제 #13
0
from flask import (
    Flask, redirect, url_for, render_template
    )
from models import app

from views.manufac  import manufac_blueprint
from views.products import prod_blueprint
from views.settings_modif import settings_blueprint
from views.appointment import appointment_blueprint

app.register_blueprint(manufac_blueprint)
app.register_blueprint(prod_blueprint)
app.register_blueprint(settings_blueprint)
app.register_blueprint(appointment_blueprint)

@app.route('/')
def index():
    return redirect('/manufac/')

if __name__ == '__main__':
    app.run(debug=True, host='127.0.0.1')
예제 #14
0
from weibo import main as weibo_routes
from user import main as user_routes
from blog import main as blog_routes
from api import main as api_routes

from models import app

# app = Flask(__name__)
# app.secret_key = 'fsdfhloip.ljhklh'
# app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
# app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///todos.db'
#
# from flask_sqlalchemy import SQLAlchemy
# db = SQLAlchemy(app)

app.register_blueprint(weibo_routes)
app.register_blueprint(user_routes)
app.register_blueprint(blog_routes, url_prefix='/blog')
app.register_blueprint(api_routes, url_prefix='/api')


@app.errorhandler(404)
def error404(e):
    return render_template('404.html')


@app.errorhandler(410)
def error404(e):
    return render_template('410.html')

예제 #15
0
"""
Flask API exposing the core endpoints needed to interact with the external API calls (from the devices)
"""
from models import BlacklistedToken, jwt, app
from app_blueprints.app_auth import app_auth_blueprint
from app_blueprints.app_organization import app_organization_blueprint
from app_blueprints.app_utils import app_utils_blueprint
from app_blueprints.app_profile import app_profile_blueprint
from app_blueprints.app_meet import app_meet_blueprint
from utils import get_generic_logger
import mongoengine

# register blueprints
app.register_blueprint(app_auth_blueprint, url_prefix="/auth")
app.register_blueprint(app_organization_blueprint, url_prefix="/organization")
app.register_blueprint(app_utils_blueprint, url_prefix="/utils")
app.register_blueprint(app_profile_blueprint, url_prefix="/profile")
app.register_blueprint(app_meet_blueprint, url_prefix="/meet")

logger = get_generic_logger(__name__)


@app.route("/debug-sentry")
def trigger_error():
    return 1 / 0


@jwt.token_in_blacklist_loader
def check_if_token_in_blacklist(decoded_token):
    jti = decoded_token["jti"]
    try: