def create_app(): app = Blueprint('client', __name__) app.debug = True from bingo.client.resources import ( Game, GameAdmin, ) resources = { Game: '/', GameAdmin: '/admin', } for resource, route in resources.items(): app.add_url_rule(route, view_func=resource.as_view(resource.__name__)) @app.route('/logout') @login_required def logout(): """ Log out a logged in user. Then redirect them back to the main page of the site. """ logout_user() return redirect(url_for('index')) return app
def create_app(): app = Blueprint('backend', __name__) app.debug = True api = Api(app) from bingo.api.resources import (Rules, Rule) resources = { Rules: '/rules', Rule: '/rules/<name>', } for resource, route in resources.items(): api.add_resource(resource, route) return app
def init(root_path): """Созадаём объект модуля.""" core = Blueprint('core', __name__) core.root_path = root_path #print ("CORE: %s"%core) core.debug = True core.add_url_rule('/', 'index', index_page) core.add_url_rule('/index.html/', 'index', index_page) core.add_url_rule('/<string:pagename>/', 'index', index_page) core.add_url_rule('/<path:pagename>/', 'index', index_page) core.add_url_rule('/edit/', 'edit', edit) core.add_url_rule('/edit/<path:page>', 'edit', edit, methods=['GET', 'POST']) return core
def create_app(): app = Blueprint('backend', __name__, url_prefix='/api') app.debug=True api = Api(app) from saltmonitor.api.resources import ( Jobs, Job, SaltReturns, SaltReturn, ) resources = { Jobs: '/jobs', Job: '/jobs/<jid>', SaltReturns: '/returns', SaltReturn: '/returns/<jid>', } for resource, route in resources.items(): api.add_resource(resource, route) return app
def create_app(): app = Blueprint('backend', __name__, url_prefix='/api') app.debug = True api = Api(app) from saltmonitor.api.resources import ( Jobs, Job, SaltReturns, SaltReturn, ) resources = { Jobs: '/jobs', Job: '/jobs/<jid>', SaltReturns: '/returns', SaltReturn: '/returns/<jid>', } for resource, route in resources.items(): api.add_resource(resource, route) return app
img_url = '/uploads/' + filename return render_template('index.html', img_url=img_url, filename=filename) else: return ''' <p>許可されていない拡張子です</p> ''' else: return redirect(url_for('')) @app.route('/api/v1/check/<filename>', methods=['GET', 'POST']) def check(filename): if request.method == 'POST': img_url = '/uploads/' + filename nyan_type = predict(filename) return render_template('index.html', img_url=img_url, nyan_type=nyan_type) else: return redirect(url_for('')) @app.route('/uploads/<filename>') def uploaded_file(filename): return send_from_directory(config['upload_dir'], filename) if __name__ == '__main__': app.debug = True app.run()
def load_yaml(yamlfile): environ = 'STAGING' with open(yamlfile, 'rb') as fp: conf = yaml.load(fp.read()) # host_conf = 'HOST:%s' % socket.gethostname() # if host_conf in conf: # return conf[host_conf] try: return conf[environ] except KeyError: raise ConfigurationError('The config file %s does not provide ' 'environment support of %s' % (yamlfile, environ)) CONF = load_yaml('/home/qisan/workspace/vocabulary/wxserver/qisan/apps/words/app.yaml') app.debug = CONF['DEBUG'] app.config.from_object(__name__) WX_TOKEN = CONF['WX_TOKEN'] DATE_FMT = CONF['DATE_FMT'] YESTERDAY = (datetime.today() - timedelta(days=1)).date().isoformat() def main(): db = DataBase(app, CONF['DBNAME'], CONF['USERNAME'], CONF['PASSWORD']) db.init() app.run(host='0.0.0.0') @app.route('/wx', methods=['GET']) def wx_get():
from flask import Blueprint from flask import Flask, send_from_directory, jsonify, render_template pygeppetto_core = Blueprint('pygeppetto_core', __name__, template_folder='org.geppetto.frontend/src/main/webapp/build') pygeppetto_core.debug = True @pygeppetto_core.route('/') def geppetto(name=None): print("Serving Geppetto Page") return render_template('geppetto.vm')
# users.append({'name' : user.name, 'email' : user.email ,'password': user.password})#dic # return jsonify({'users' : users}) # @main.route('/profile/<string:id>') # def get_user_profile(id): # try: # user_id = id # print(user_id) # user_data=Users.query.filter_by(id=user_id).first() # print(user_data) # # users_schema =UsersSchema(many=True) # # users_schema =UsersSchema() # # output=users_schema.dump(user_data) # # print(output) # if bool(user_data) :# dict is not empty # # return jsonify('Done'),200 # return {'name' : user_data.name, 'email' : user_data.email} # else: # return jsonify('get user profile error'),400# error geting user # except: # return jsonify('something went worng , Please try again'),400 if __name__ == '__main__': # Threaded option to enable multiple instances for multiple user access support main.debug= True main.run(threaded=True, port = int(os.environ.get('PORT', 5000)))
:url: http://greyli.com :copyright: © 2018 Grey Li <*****@*****.**> :license: MIT, see LICENSE for more details. """ from flask import render_template, redirect, url_for, request, Blueprint, current_app, abort, flash from flask_login import current_user, login_required from flask_socketio import emit import socket, binascii, threading from catchat.extensions import socketio, db from catchat.forms import ProfileForm from catchat.models import Message, User from catchat.utils import to_html, flash_errors chat_bp = Blueprint('chat', __name__) chat_bp.debug = True online_users = [] # 服务端接收消息并且广播消息 @socketio.on('new message') def new_message(message_body): # 将HTML传过来的格式数据包转为Python格式 # html_message = to_html(message_body) html_message = '测试数据' # 将数据包存储在数据库 print(current_user) message = Message(author=current_user._get_current_object(), body=html_message) db.session.add(message)
from mappening.api.models.user import User from mappening.api import users from mappening.auth.google import google_oauth from flask import Flask, jsonify, redirect, url_for, session, request, Blueprint from flask_login import UserMixin, LoginManager, login_required, current_user, login_user, logout_user from flask_cors import CORS from flask_oauth import OAuth from datetime import datetime import json # Route Prefix: /auth auth = Blueprint('auth', __name__) DEBUG = True auth.debug = DEBUG # Flask-Login - configure application for login login_manager = LoginManager() # Required to allow Blueprints to work with flask_login # on_load is run when Blueprint is first registered to the app # Enable session protection to prevent user sessions from being stolen # By default is in "basic" mode. Can be set to "None or "strong" @auth.record_once def on_load(state): login_manager.init_app(state.app) # login_manager.session_protection = "strong" print("Login manager set up with auth Blueprint!")
pullID = request.args.get('pullID', type=int) if fo != "json": return ("", "501: only json is supported for format.") else: result = DB.fetch_pull(query, pullID) header = {'Content-Type': 'application/json'} data = json.dumps(result) return (data, header) ################################################################################ # GitHub - Taiga Overlap # ex: 127.0.0.1:5000/github/commits_on_stories?projectSlug="someSlug"&repoName="someRepo" # Returns commit information in someRepo for each user story in the project with someSlug @github_api.route('/commits_on_stories', methods=('GET', 'POST')) def api_get_commits_on_stories(): projectSlug = request.args.get('projectSlug') repoName = request.args.get('repoName') commitOnStoryData = DB.get_commits_on_stories(projectSlug) data = json.dumps(commitOnStoryData) return (data, {'Content-Type': 'application/json'}) if __name__ == '__main__': github_api.debug = True github_api.run()