def runserver(host, port): """Run a development server.""" reload_on_files = current_app.config['RELOAD_ON_FILES'] current_app.run(host=host, port=port, extra_files=reload_on_files, threaded=True)
def run(self, host=None, port=None): services.run_crawler_service() host = host or current_app.config['HOST'] port = port or current_app.config['PORT'] current_app.run(host=host, port=port)
def run(self, parser, args): kwargs = {} if args.all_interfaces: kwargs['host'] = '0.0.0.0' kwargs['debug'] = not args.no_debug kwargs['port'] = args.port current_app.run(**kwargs)
def run(): """ Command to run the API locally. """ port = int(current_app.config['PORT']) host = current_app.config['HOST'] debug = current_app.config['DEBUG'] current_app.run(host=host, port=port, debug=debug)
def run(): """ Runs the api server """ port = int(current_app.config["PORT"]) host = current_app.config["HOST"] debug = current_app.config["DEBUG"] current_app.run(host=host, port=port, debug=debug)
def runserver(port, debug): """Runs the Flask development server i.e. app.run().""" if debug is not None: current_app.debug = debug if not port: port = current_app.config['PORT'] click.echo('* Running on http://127.0.0.1:%s/ (Press CTRL+C to quit)' % port) current_app.run(port=port)
def run(): # pragma: no cover """Run a server directly.""" from .logs import configure_logging print('Direct start, use of gunicorn is recommended for production.', file=sys.stderr) # noqa port = current_app.config['PORT'] host = current_app.config['HOST'] debug = current_app.config['DEBUG'] init_filesystem(current_app) configure_logging(current_app) current_app.run(host=host, port=port, debug=debug)
def nasa_image(): today = str(data.today()) response = requests.get( 'https://api.nasa.gov/planetary/apod?api_key=0hnWqUOzCWnNqLNddglJPGiG56sTs0PXg2hPY7MV&date=' + today) data = response.json() return render_template('nasa.html', data=data) if __name__ == '_main__': app.run(debug=True, host='127.0.0.1')
def serve(server='0.0.0.0', port=5000, debug=DEBUG): """ Serves this site. """ if not debug: import logging file_handler = FileHandler("error.log") file_handler.setLevel(logging.WARNING) app.logger.addHandler(file_handler) asset_manager = app.extensions['asset_manager'] asset_manager.config['ASSETS_DEBUG'] = debug app.debug = debug app.run(host=server, port=port, debug=debug)
def serve(port, **kwargs): """Runs the flask development server""" with app.app_context(): kwargs["threaded"] = kwargs.get("threaded", app.config["PARALLEL"]) kwargs["debug"] = app.config["DEBUG"] if app.config.get("SERVER_NAME"): parsed = urlsplit(app.config["SERVER_NAME"]) host, port = parsed.netloc, parsed.port or port else: host = app.config["HOST"] kwargs.setdefault("host", host) kwargs.setdefault("port", port) app.run(**kwargs)
def cli(): parser = argparse.ArgumentParser() parser.add_argument("-p", "--port", default=8080, help="Port at which the service will listen on") parser.add_argument("-d", "--debug", action='store_true', help="Enables debug logging") args = parser.parse_args() try: print("Starting serializer!") app.run(host='0.0.0.0', port=int(args.port), threaded=True) except Exception as e: # This doesn't do anything print("Caught exception : {}".format(e)) exit(-1)
def analyse(): class inputform(FlaskForm): query = StringField('Enter the term you want to analyse.', validators=[DataRequired()]) submit = SubmitField('Gather Data') form = inputform() if form.is_submitted(): #twload(form.query.data) #ytload(form.query.data) if True: p = Process(target=twload, args=(form.query.data, )) p.start() p.join() app = create_app() if __name__ == "__main__": app.run(debug=True) flash( f'Almost done! Now CLICK on Dashboard to start creating your analytics dashboard for {form.query.data}.', 'success') return redirect(url_for('home')) return render_template('analyse.html', title='Analyse', form=form)
return input_value.strftime(format_) # @app.route('/curriculum') # def cv(): # return render_template('curriculum.html') @app.route('/tec_laguna') def tec_laguna(): return render_template('tec_laguna.html') settingsClass = settings.Settings(app.config) postClass = post.Post(app.config) userClass = user.User(app.config) app.jinja_env.globals['url_for_other_page'] = url_for_other_page app.jinja_env.globals['csrf_token'] = generate_csrf_token app.jinja_env.globals['meta_description'] = app.config['BLOG_DESCRIPTION'] app.jinja_env.globals['recent_posts'] = postClass.get_posts(10, 0)['data'] app.jinja_env.globals['tags'] = postClass.get_tags()['data'] if not app.config['DEBUG']: import logging from logging import FileHandler file_handler = FileHandler(app.config['LOG_FILE']) file_handler.setLevel(logging.WARNING) app.logger.addHandler(file_handler) if __name__ == '__main__': app.run(host="0.0.0.0", port=int(os.environ.get("PORT", 8080)), debug=app.config['DEBUG'])
def runserver(port=5000): app.run(threaded=True, port=int(port))
def profile(): current_app.config['PROFILE'] = True current_app.wsgi_app = ProfilerMiddleware(current_app.wsgi_app, restrictions=[30]) current_app.run(debug=True)
@app.route('/') def home_endpoint(): return render_template('home.html') @app.route('/predict', methods=['POST']) def get_prediction(): image = request.files['file'] if image.filename != '': fn = os.path.join(app.config['UPLOAD_FOLDER'], image.filename + str(datetime.now().time())) image.save(fn) image = load_image(fn) res, preprocessed_image = inference(image) preprocessed_image = Image.fromarray(np.uint8(preprocessed_image * 255)).convert('RGB') buffer = BytesIO() preprocessed_image.save(buffer, format="PNG") myimage = buffer.getvalue() return jsonify(message=res, image=str(base64.b64encode(myimage))[2:-1]) if __name__ == '__main__': model = None load_model('model') app.run(host="0.0.0.0", port=int(os.environ.get("PORT", 5000)))
def all_movies(): return jsonify(json_info) @app.route('/api/v1/movies/search_title', methods=['GET']) def search_title(): results = [] if 'title' in request.args: title = request.args['title'] for movie in json_info: if title in movie['title']: results.append(movie) if len(results) < 1: return "No results found" return render_template("index.html", results=results) if __name__ == '__main__': app.run(debug=True, host='127.0.0.1') # @app.route('/nasa') # def nasa_image(): # today = str(date.today()) # response = requests.get('https://api.nasa.gov/planetary/apod?api_key=wjlnR0Xw9B5Sh3WEIJa9kmVd368hNMiUVIGahGPi&date='+today) # data = response.json() # return render_template('nasa.html',data=data)
def run(self, options): app.run(options.host, options.port, debug=options.debug)
mongo = db.establish_mongo_connection(app) app.mongo = mongo # Config secret key app.secret_key = settings.secret_key # Routes app.add_url_rule('/adminnew', view_func=Admin.as_view('admin'), methods=["GET", "POST"]) app.add_url_rule('/adminnew/users', view_func=Users.as_view('users'), methods=["GET", "POST"]) app.add_url_rule('/adminnew/transactions', view_func=UserTransactions.as_view('transactions'), methods=["GET"]) app.add_url_rule('/adminnew/cronjobs', view_func=Cronjobs.as_view('cronjobs'), methods=["GET"]) app.add_url_rule('/adminnew/emails', view_func=Emails.as_view('emails'), methods=["GET"]) app.add_url_rule('/adminnew/unsubscribes', view_func=Unsubscribes.as_view('unsubscribes'), methods=["GET"]) # Run app in debug mode app.run(debug = 'TRUE')
result=g.dbHandler.postRating(req_json) return jsonify({"rating":result}) @app.route('/post/like_dislike',methods=['POST']) def postLikeDislike(): req_json=request.get_json() result=g.dbHandler.postLikeDislike(req_json) return jsonify({"like_dislike":result}) @app.route('/create/user',methods=['POST']) def createUser(): req_json=request.get_json() result=g.dbHandler.createUser(req_json) return jsonify({"user":result}) @app.route('/user/search',methods=['POST']) def searchUser(): req_json=request.get_json() result=g.dbHandler.searchUser(req_json) return jsonify({"user":result}) handler = logging.FileHandler('bh-api.log') handler.setLevel(logging.WARNING) formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') handler.setFormatter(formatter) app.logger.addHandler(handler) if __name__ == "__main__": app.run(host='0.0.0.0',port=5000,debug=True)
def run(port=5000): current_app.run(port=port, debug=True)
def runserver(port=5000): app.run(port=int(port))
def run_debug(): current_app.debug = True current_app.run("0.0.0.0")
def run(): """Run in local machine.""" port = int(os.environ.get("PORT", 5000)) current_app.run(host='0.0.0.0', port=port, debug=True)
def runserver(host='127.0.0.1'): "Run stand alone test server" logging.getLogger().setLevel(logging.INFO) db.create_all() current_app.run(host=host, debug=False)
@app.route('/progress/<layer_name>') @cross_origin(origins='*') def process_progress(layer_name): if layer_name not in progress_map: progress = {'download_size': 'unknown', 'layer_name': 'unknown', 'progress': 0, 'total_size': 'unknown', 'status': 'unknown'} return jsonify(progress=progress) return jsonify(progress=progress_map[layer_name]) @app.route('/kill/<key>') @cross_origin(origins='*') def kill(key): percent_done = thread_manager_processes[threads_map_key][key].percent_done() del thread_manager_processes[threads_map_key][key] done = True percent_done = round(percent_done, 1) return jsonify(key=key, percent=percent_done, done=done) @app.route('/list/keys') @cross_origin(origins='*') def list_keys(): urls = [] for t in name_list: urls.append('http://127.0.0.1:5000/progress/' + t) return jsonify(keys=urls) if __name__ == '__main__': app.run(debug=True)
@app.route('/api/v1/albums/search', methods=['GET']) def albums_search(): results = [] if 'artist' in request.args: artist = request.args['artist'] for album in albums: if artist in album['artist']: results.append(album) if 'year' in request.args: year = request.args['year'] for album in albums: if (year == str(album['year'])): results.append(album) if 'song' in request.args: song = request.args['song'].lower() for album in albums: for s in album['songs']: if song in s.lower(): results.append(album) if (len(results) < 1): return "No matches found" else: return render_template("albums.html", albums=results) if __name__ == '__main__': app.run(debug=True, host="0.0.0.0")
form = LoginForm(request.form) if form.validate_on_submit(): log.info('Request submitted') form_data = form.data user = User.authenticate(form_data['email'], form_data['password']) if user: login_user(user) return render_template('login.html', form=form) @auth.route('/logout', methods=['GET']) def logout(): if current_user.is_authenticated: logout_user() return redirect(url_for('.login')) class LoginForm(Form): email = EmailField(validators=[validators.Required(), validators.Email()]) password = PasswordField(validators=[validators.Required()]) if __name__ == '__main__': current_app.run()
from eve import Eve from flask import render_template, render_template_string, request, current_app as app app = Eve(__name__, template_folder='templates') @app.route('/test') def test(): return render_template('index.html') @app.route('/test.js') def test_js(): return render_template('test.js') #@app.route('/annotations/annotations') #def store(): # return render_template('store.html') if __name__ == '__main__': app.run(debug=True, host="0.0.0.0", threaded=True)
from eve import Eve from eve.auth import HMACAuth from flask import current_app as app from hashlib import sha1 import hmac from config import config class HMACAuth(HMACAuth): def check_auth(self, userid, hmac_hash, headers, data, allowed_roles, resource, method): # use Eve's own db driver; no additional connections/resources are # used accounts = app.data.driver.db['accounts'] user = accounts.find_one({'userid': userid}) if user: secret_key = user['secret_key'] # in this implementation we only hash request data, ignoring the # headers. return user and \ hmac.new(str(secret_key).encode(), data, sha1).hexdigest() == \ hmac_hash app = Eve(settings=config, auth=HMACAuth) #app = Eve(settings=config) app.run()
from flask import Response, Flask, request, current_app as app import os app = Flask(__name__) @app.route("/") def indexPage(): return "Hello 123" @app.route("/add", methods=["GET", "POST"]) def thanksPage(): a=request.args.get('A') b=request.args.get('B') return str(int(a)+int(b)) if __name__ == "__main__": port = int(os.environ.get("PORT", 5000)) app.run(host='0.0.0.0', port=port, debug=True)
def start(host, port): current_app.run(host=host, port=port)
def run(): port = int(os.environ.get('PORT', 5000)) current_app.run(host='0.0.0.0', port=port)
db.commit() def connect_db(): return sqlite3.connect(app.config['DATABASE']) @app.before_request def before_request(): g.db = connect_db() @app.teardown_request def teardown_request(exception): g.db.close() @app.after_request def after_request(response): return response if __name__ == "__main__": app.debug = True app.config.from_object("config") init_session() init_db() app.run(host="0.0.0.0", port=8080)
from flask import Flask, render_template, request, url_for from flask import current_app as app # Define a route for the default URL, which loads the form @app.route('/') def form(): return render_template('templates/concept_creation.html') @app.route('/hello/', methods=['POST']) def hello(): name=request.form['yourname'] email=request.form['youremail'] return render_template('form_action.html', name=name, email=email) # Run the app :) if __name__ == '__main__': app.run( host="0.0.0.0", port=int("80") )
list(cri_in_tracer_records - cri_in_outbound_messages), "extra_records": list(cri_in_outbound_messages - cri_in_tracer_records) } return jsonify(data) # END ROUTES # def init_app(): app.url_map.strict_slashes = False app.config.from_object("Config.BaseConfig") if app.debug is not True: file_handler = RotatingFileHandler('made_easy.log', maxBytes=1024 * 1024 * 100, backupCount=20) file_handler.setLevel(logging.ERROR) formatter = logging.Formatter( "%(asctime)s - %(name)s - %(levelname)s - %(message)s") file_handler.setFormatter(formatter) app.logger.addHandler(file_handler) if __name__ == '__main__': with app.app_context(): init_app() app.run(port=app.config.get("PORT"))
im_small = im.copy() im_small.thumbnail(bounds(size), Image.ANTIALIAS) filename = "%s_%s%s" % (basename, slug, extension) im_small.save(os.path.join(PHOTO_FOLDER, id, filename )) update['urls'][slug] = 'http://' + SERVER_NAME + '/static/photos/' + id + '/' + filename update['urls']['original'] = 'http://' + SERVER_NAME + '/static/photos/' + id + '/' + photo['filename'] update['processed'] = True # set the `url` fields for this photo in the database, so the app can display the photo app.data.driver.db.photos.update({"id": id}, { "$set": update}) # Send out a push message to all users in the vicinity of the spotted photo # (as defined in alerts.py) rainbow_spotted_alert(photo) def after_update_photos(request, payload): """ Right now the photo is uploaded in two parts: first the metadata, then the photo itself. The latter request is an `update` request. After this request, we want to create the thumbnails """ write_photo_versions(request.form['id']) app = Eve(settings=eve_settings, auth=SimpleTokenAuth, static_folder=STATIC_FOLDER) app.on_post_PATCH_photos += after_update_photos if __name__ == '__main__': app.run(debug=True, host='0.0.0.0')
def run(): port = int(current_app.config['PORT']) host = current_app.config['HOST'] debug = current_app.config['DEBUG'] current_app.run(host=host, port=port, debug=debug)
def runserver(port): app.run('127.0.0.1', port=int(port))
cursor.execute(sql) data=cursor.fetchall() return render_template('page.html', output_data =data) @app.route('/database') def database(): #if request.method =='GET': connection = pymysql.connect(host='mongodb0.example.com', user='******', password='******', db='sx6525ir_Geo', charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) sql ="SELECT * From places" cursor.execute(sql) data=cursor.fetchall() return render_template('page.html', output_data =data) if __name__ == '__main__': app.run(debug=True, port=27016)
def runserver(): current_app.run(debug=True, host='0.0.0.0')
from flask import Flask, render_template, request, json, jsonify, current_app as app from datetime import date import os import requests app = Flask(__name__) @app.route('/holiday') def pic(): response = requests.get('https://date.nager.at/api/v2/PublicHolidays/2021/ISO 3166-2:GH') if __name__ == '__main__': app.run(debug=True, host='0.0.0.0')
from life_tracker.flask_app import create_app from life_tracker.backend.models import * from flask import current_app as app from flask_login import current_user, login_user app = create_app() @app.shell_context_processor def make_shell_context(): context = { 'app': app, 'current_user': current_user, 'AppUser': AppUser, } return context if __name__ == "__main__": app.run(host='0.0.0.0')
return predict_response( status=afy_flask_predict_status.NO_PREDICTOR, error="Predictor not available") return predict_response( status=afy_flask_predict_status.INPUT_IMAGE_ERROR, error="Invalid image / image corrupted") except Exception as e: if app.verbose: traceback.print_exc() return predict_response(error=str(e)) @app.route('/avatarify/<token>/logout', methods=['GET']) def logout(token): try: vprint("Processes: ", app.processes) vprint("Predictors: ", app.predictors) if token in app.processes: d = app.processes.pop(token) predictor = d['predictor'] app.predictors.append(predictor) return logout_response(afy_flask_logout_status.SUCCESS) except Exception as e: if app.verbose: traceback.print_exc() return logout_response(error=str(e)) if __name__ == '__main__': app.run(host='0.0.0.0', port=8093, debug=app.verbose)
# @socketio.on('disconnect') # def test_disconnect(): # print('Client disconnected') if __name__ == '__main__': parser = argparse.ArgumentParser(description='face model test') parser.add_argument('--image-size', default='112,112', help='') # parser.add_argument('--model', default='model_50/model-0000, 0', help='path to load model.') parser.add_argument('--model', default='./deploy_models/model_alignt_person/model,792', help='path to load model.') parser.add_argument('--mtcnn_model', default='./deploy_models/mtcnn-model/', help='path to load model.') parser.add_argument('--retinaface', default=True, type=bool, help='true : RetinaFace, false : MTCNN') parser.add_argument('--retina_model', default='deploy_models/retina_model/retina') parser.add_argument("--retina_epoch", help="test epoch", default="1220", type=int) parser.add_argument('--ga-model', default='', help='path to load model.') parser.add_argument('--gpu', default=0, type=int, help='gpu id') parser.add_argument('--det', default=0, type=int, help='mtcnn option, 1 means using R+O, 0 means detect from begining') parser.add_argument('--threshold', default=0.4, type=float, help='ver dist threshold') parser.add_argument('--flip', default=0, type=int, help='whether do lr flip aug') # parser.add_argument('--db_path', default="db_full_792.npy", type=str, help='path to .npy db') parser.add_argument('--db_path', default="./db/db_full_1081120.npy", type=str, help='path to .npy db') # parser.add_argument('--db_path', default="/mnt/hdd1/SOD/SOD_FR/db/db_full.npy", type=str, help='path to .npy db') args = parser.parse_args() fmodel = face_model.FaceModel(args) socketio.run(app, debug=True, host='0.0.0.0') app.run(debug=True, host='0.0.0.0', port=5555) # app.run(debug=True, host='0.0.0.0', ssl_context=('ssl/server.crt', 'ssl/server.key'))
print('Hello') # f.save(os.path.join(app.config['UPLOADED_PATH'], f.filename)) s3.upload(f,'test_folder/'+f.filename) return render_template('index.html') @app.route('/result', methods=['POST', 'GET']) def result(): c=prediction.predict_res() print(c) return render_template('tables.html',c=c) @app.route('/custom', methods=['POST', 'GET']) def custom(): c=request.form.to_dict() imagerotation=c['imagerotation'] zoomrange=c['zoomrange'] widthshift=c['widthshift'] horizantalshift=c['horizantalshift'] verticalflip=c['verticalflip'] model=c['model'] batchsize=c['batchsize'] epochs=c['epochs'] stepsepoch=c['stepsepoch'] validation=c['validation'] print(c) return render_template('train.html',c=c) if __name__ == '__main__': app.run(debug=True)
def run_prod(): current_app.debug = False current_app.run("0.0.0.0")