from flask import Flask, request, jsonify, render_template from uuid import uuid4 from .models import Raw_data, db, raw_data_schema, raw_datas_schema from .swagger import SWAGGER_URL, API_URL, SWAGGERUI_BLUEPRINT from api import app from os import environ as env from uuid import uuid4 ### swagger specific ### app.register_blueprint(SWAGGERUI_BLUEPRINT, url_prefix=SWAGGER_URL) ## UI @app.route('/showall') def showall(): return render_template('showall.html', passengers=Raw_data.query.all()) @app.route('/') def home(): return render_template('home.html') # Create a Data @app.route('/people', methods=['POST']) def add_data(): uuid = uuid4() try: survived = request.json['survived'] passengerClass = int(request.json['passengerClass']) name = request.json['name']
from api import app, api_path from api.rest.user_routes import user from api.rest.team_routes import team from flask_cors import CORS cors = CORS(app, resources={r"*": {"origins": "*"}}) app.register_blueprint(user, url_prefix=api_path) app.register_blueprint(team, url_prefix=api_path) if __name__ == "__main__": app.run(debug=True)
"""Run File""" from api import app from api import routes from flask import render_template # Register API Blueprint app.register_blueprint(routes.mod) # Route to Index Page @app.route('/') def index(): """Route to Index Page""" return render_template('documentation.html') if __name__ == '__main__': """Starts Flask Server Once File is run""" app.run(debug=True)
from .resources.tables import Results, History, UserResults #import flask_login from api.models.course import Course from api.models.user import User from api.common.cypher_helpers import page_number, page_size # Wrap app with API to enable Flask-REST API api_bp = Blueprint('api', __name__) api = Api(api_bp) api.add_resource(AuthorsResource, '/authors') api.add_resource(AuthorResource, '/authors/<int:id>') api.add_resource(EnrollResource, '/enroll') # api.add_resource(CoursesResource, '/courses') app.register_blueprint(api_bp) app.secret_key = b'_5#y2L"F4Q8z\n\xec]/' # ============================================================================= # login_manager = flask_login.LoginManager() # # @login_manager.user_loader # def load_user(user_id): # return User.get(user_id) # ============================================================================= @app.route('/', methods=['GET', 'POST']) def index(): if 'username' in session:
# import time # import thread from api import app # from api import sensitive_words from api.config import BaseConfig from api.service import sensitive_word_bp from api.service import sensitive_word_reload_bp # # 创建定期更新敏感词线程函数 # def update_sensitive_word(): # try: # while True: # readliens = open(BaseConfig.WORD_PATH, 'r').readliens() # for line in readliens: # line = line.strip() # if not line: # continue # sensitive_words.add_word(line, line) # sensitive_words.make_automaton() # time.sleep(int(BaseConfig.WORD_UPDATE_FREQUENCY)) # return True # except Exception as e: # app.logger.error("update_sensitive_word exception:{}".format(e)) # return False # thread.start_new_thread(update_sensitive_word) URL_PREFIX = BaseConfig.APPLICATION_ROOT app.register_blueprint(sensitive_word_bp, url_prefix=URL_PREFIX) app.register_blueprint(sensitive_word_reload_bp, url_prefix=URL_PREFIX)
@app.route("/api/doc_classic/") @app.route("/api/doc_classic/<path:path>") def swagger_index(path=None): if not path or path == '/': path = 'index.html' root_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) return send_from_directory(root_dir, "swagger/%s" % path, as_attachment=False) SWAGGER_URL = '/api/doc' # URL for exposing Swagger UI (without trailing '/') API_URL = '/api/doc/swagger.yaml' swaggerui_blueprint = get_swaggerui_blueprint( SWAGGER_URL, # Swagger UI static files will be mapped to '{SWAGGER_URL}/dist/' API_URL ) app.register_blueprint(swaggerui_blueprint, url_prefix=SWAGGER_URL) # app.router.add_route('POST', "/api/v1/extra_multisig_info", ExtraMultisigInfoEndpoint) # app.router.add_route('POST', "/api/v1/outputs", OutputsEndpoint) # # tx endpoints # app.router.add_route('POST', "/api/v1/tx_proposals", TxProposalNewEndpoint) # app.router.add_route('GET', "/api/v1/tx_proposals", TxProposalListEndpoint) # app.router.add_route('GET', "/api/v1/tx_proposals/{proposal_id}", ProposalInfoEndpoint) # app.router.add_route('PUT', "/api/v1/tx_proposals/{proposal_id}/decision", ProposalDecisionEndpoint)
from api import app from .resources.users import user app.register_blueprint(user)
from api import app import users import slots import patines app.register_blueprint(users.users_api) app.register_blueprint(slots.slots_api) app.register_blueprint(patines.patines_api) @app.route("/api/index") def hello(): return "GoPatines!" if __name__ == '__main__': app.run(host='0.0.0.0', debug=True)
def installer(prefix): app.register_blueprint(bp_crawler, url_prefix=prefix + '/crawler') # /api/crawler .. bla bla
from api import app from . import user, blog modules_define = [user.mod, blog.mod] for view in modules_define: app.register_blueprint(view)
import json from flask import Response from v1.views import api_v1 from v2.views import api_v2 from api import app, db from api.errors import * app.register_blueprint(api_v1, url_prefix='/v1') app.register_blueprint(api_v2, url_prefix='/v2') @app.route('/', methods=['GET']) def index(): data = {"message": "Welcome to my API :)"} return Response(json.dumps(data), 200, mimetype='application/json')
from flask import render_template from configuration import Options from api import app from api.pages import admin_page, contact_page, favicon_page, player_page, upload_page, errors_page app.register_blueprint(admin_page) app.register_blueprint(contact_page) app.register_blueprint(favicon_page) app.register_blueprint(player_page) app.register_blueprint(upload_page) app.register_blueprint(errors_page) @app.route('/', methods=['GET']) def index(): yt_file = open("youtube_url.txt", "r") return render_template('index.html', youtube_embed_url=yt_file.readline()) if __name__ == '__main__': # Start serving app.run(host='0.0.0.0', port=Options.detection_service_port, threaded=True, debug=False)
from flask_script import Manager from api import app, db, celery app.config.from_object(os.environ['APP_SETTINGS']) migrate = Migrate(app, db) manager = Manager(app) manager.add_command('db', MigrateCommand) # App Register from api.employee import employee_blueprint from api.device import device_blueprint app.register_blueprint(employee_blueprint) app.register_blueprint(device_blueprint) celery.conf.update(app.config) @manager.command def runserver(): """ overriding the runserver command """ app.run() if __name__ == '__main__': manager.run()
user.authenticated = True user.anonymous = True user.active = True user.put() session['user_id'] = me.data['email'] session['_fresh'] = True flash('Logged in successfully.') return redirect(urlservice) @google.tokengetter def get_google_oauth_token(): return session.get('google_token') def access(f): def wrapper(*args, **kwargs): if 'google_token' in session: me = google.get('userinfo') try: if me.data['email'].split("@")[1] == "salusglobalp.com": return True else: return False except: return False else: return False return wrapper app.register_blueprint(adminauth, url_prefix='/adminauth')
from api.blueprints.job import reconfig # Apps from api.blueprints.system import backup from api.blueprints.system import doctor from api.blueprints.system import email from api.blueprints.system import license as avlicense from api.blueprints.system import config from api.blueprints.system import status as system_status # Attach blueprints. API_VERSION = "1.0" API_URL_BEGIN = "/av/api/%s/" % API_VERSION # auth app.register_blueprint(auth.blueprint, url_prefix=API_URL_BEGIN + 'auth') # sensor app.register_blueprint(sensor.blueprint, url_prefix=API_URL_BEGIN + 'sensor') app.register_blueprint(interfaces.blueprint, url_prefix=API_URL_BEGIN + 'sensor') app.register_blueprint(ossec_win_deploy.blueprint, url_prefix=API_URL_BEGIN + 'sensor') app.register_blueprint(iftraffic.blueprint, url_prefix=API_URL_BEGIN + 'sensor') app.register_blueprint(detector.blueprint, url_prefix=API_URL_BEGIN + 'sensor') app.register_blueprint(ossec_agent.blueprint, url_prefix=API_URL_BEGIN + 'sensor') app.register_blueprint(ossec.blueprint, url_prefix=API_URL_BEGIN + 'sensor') app.register_blueprint(ossec_configuration.blueprint, url_prefix=API_URL_BEGIN + 'sensor') app.register_blueprint(ntop.blueprint, url_prefix=API_URL_BEGIN + 'sensor') # server app.register_blueprint(server.blueprint, url_prefix=API_URL_BEGIN + 'server')
from api import app # Import all required modules from flask_cors import CORS, cross_origin from api.default import default #from api.error import error from api.insurance import insurance # Register Blueprints cors = CORS(app, resources={r"/api/*": {"origins": "*"}}) app.register_blueprint(insurance, url_prefix='/insurance') app.register_blueprint(default, url_prefix='/') # app.register_blueprint(error, url_prefix='/error')
from api.blueprints.job import reconfig # Apps from api.blueprints.system import backup from api.blueprints.system import doctor from api.blueprints.system import email from api.blueprints.system import license as avlicense from api.blueprints.system import config from api.blueprints.system import status as system_status # Attach blueprints. API_VERSION = "1.0" API_URL_BEGIN = "/av/api/%s/" % API_VERSION # auth app.register_blueprint(auth.blueprint, url_prefix=API_URL_BEGIN + 'auth') # sensor app.register_blueprint(sensor.blueprint, url_prefix=API_URL_BEGIN + 'sensor') app.register_blueprint(interfaces.blueprint, url_prefix=API_URL_BEGIN + 'sensor') app.register_blueprint(ossec_win_deploy.blueprint, url_prefix=API_URL_BEGIN + 'sensor') app.register_blueprint(iftraffic.blueprint, url_prefix=API_URL_BEGIN + 'sensor') app.register_blueprint(detector.blueprint, url_prefix=API_URL_BEGIN + 'sensor') app.register_blueprint(ossec_agent.blueprint, url_prefix=API_URL_BEGIN + 'sensor') app.register_blueprint(ossec.blueprint, url_prefix=API_URL_BEGIN + 'sensor') app.register_blueprint(ossec_configuration.blueprint, url_prefix=API_URL_BEGIN + 'sensor')
import json from flask import Response from v1.views import api_v1 from v2.views import api_v2 from api import app, db from api.errors import * app.register_blueprint(api_v1, url_prefix="/v1") app.register_blueprint(api_v2, url_prefix="/v2") @app.route("/", methods=["GET"]) def index(): data = {"message": "Welcome to my API :)"} return Response(json.dumps(data), 200, mimetype="application/json")