Пример #1
0
def main():
    args = parse_args()
    async_mode = 'gevent'  # eventlet, gevent_uwsgi, gevent, threading

    logger.info('Running automate version {}', Env.version)
    from utils.io import delete_old_files
    delete_old_files(Env.tmp)

    # -------------------------------------------------------------------------

    if args.debug:
        async_mode = 'threading'
        Env.debug_mode = True
    else:
        from gevent import monkey
        monkey.patch_all()

    # -------------------------------------------------------------------------

    from flask_socketio import SocketIO
    import flask
    from www import app

    # -------------------------------------------------------------------------

    socketio = SocketIO(app,
                        json=flask.json,
                        async_mode=async_mode,
                        ping_interval=100 * 1000)
    register_routes(app, socketio)

    # -------------------------------------------------------------------------

    if args.backdoor:
        from www import backdoor
        backdoor.register_routes(app, socketio)

    # -------------------------------------------------------------------------

    logger.info('Listening on {host}:{port} (debug={debug})', **vars(args))
    Env.dump_info('Configuration in env.py')
    logger.info('removing old files from {}', Env.tmp)

    # -------------------------------------------------------------------------

    if args.debug:
        app.run(debug=args.debug, host=args.host, port=args.port)
    else:
        from geventwebsocket import WebSocketServer
        http_server = WebSocketServer((args.host, args.port), app)
        http_server.serve_forever()

    return app, args
Пример #2
0
from www import app
app.run(debug=True,port=3080)
Пример #3
0
    app.jinja_env.filters['format_log'] = format_log

    def hash_name(s):
        a = s.replace("\\", "_").replace("/", "_")
        m = hashlib.sha1()
        m.update(a.encode())
        digest = m.digest()
        digest64 = binascii.b2a_hex(digest).decode()
        return digest64

    app.jinja_env.filters['hash_name'] = hash_name

    def tohtml_logurl(s):
        idx = s.find("?")
        if idx != -1:
            s = s[:idx]
        return s

    app.jinja_env.filters['tohtml_logurl'] = tohtml_logurl

    def format_date(d):
        # Example: 2015-04-14T16:05:07.000+0000
        return dateutil.parser.parse(d).strftime("%b %e, %Y")

    app.jinja_env.filters['date'] = format_date

    app.config["TEMPLATES_AUTO_RELOAD"] = True

    app.run(HOST, PORT, debug=False)
Пример #4
0
def main():
    args = parse_args()
    async_mode = 'gevent'  # eventlet, gevent_uwsgi, gevent, threading

    logger.info('Running automate version {}', Env.version)
    from utils.io import delete_old_files
    delete_old_files(Env.tmp)

    # -------------------------------------------------------------------------

    if args.debug:
        async_mode = 'threading'
        Env.debug_mode = True
    else:
        from gevent import monkey
        monkey.patch_all()

    # -------------------------------------------------------------------------

    from flask_socketio import SocketIO
    import flask
    from www import app

    # -------------------------------------------------------------------------

    socketio = SocketIO(app,
                        json=flask.json,
                        async_mode=async_mode,
                        ping_interval=100 * 1000)
    register_routes(app, socketio)

    # -------------------------------------------------------------------------

    if args.backdoor:
        from www import backdoor
        backdoor.register_routes(app, socketio)

    # -------------------------------------------------------------------------

    logger.info('Listening on {host}:{port} (debug={debug})', **vars(args))
    Env.dump_info('Configuration in env.py')
    logger.info('removing old files from {}', Env.tmp)

    # -------------------------------------------------------------------------
    # from database.mongo import Mongo
    # ns = []
    # events = Mongo().events.find(({}))
    # for e in events:
    #     eid = str(e["_id"])
    #     if isinstance(e["to"], dict):
    #         did = e["document"]
    #         doc = Mongo().result_by_id(did)
    #         no_comment = doc.review is None
    #         user = e["to"]["id"]
    #         if no_comment:
    #             Mongo().update_event_fields(eid, to=user)
    #             ns.append(eid)
    # print(ns)
    # exit(0)

    # -------------------------------------------------------------------------

    if args.debug:
        app.run(debug=args.debug, host=args.host, port=args.port)
    else:
        from geventwebsocket import WebSocketServer
        http_server = WebSocketServer((args.host, args.port), app)
        http_server.serve_forever()

    return app, args
Пример #5
0
#!/usr/bin/env python
from www import app
app.run(host='0.0.0.0', debug=True)
from www import app

HOST = 'localhost'  # This restricts incoming calls to the local machine
#HOST = '0.0.0.0'     # This allows incoming calls from outside the machine (Windows will ask for Firewall permission)
PORT = 7882  # Arbitrary port (epoch accessible from outside)

import platform
hostname = platform.uname()[1]

print("HOSTNAME = %s" % hostname)

# Better default choice than True
debug = False
if hostname.endswith('herald'):
    debug = True

## http://blog.rootsmith.ca/uncategorized/request-server-or-hostname-must-match-flasks-server_name-to-route-successfully/
#import os
#if 'SERVER_NAME' in os.environ:
#    print os.environ['SERVER_NAME']

app.run(
    host=HOST,
    port=PORT,
    debug=debug,
)
Пример #7
0
from flask import Blueprint, render_template, redirect, request, url_for, jsonify
from www import app
from cv2 import cv2
import os
from werkzeug.utils import secure_filename
from flask import jsonify
import pytesseract
from PIL import Image


upload = Blueprint('upload',__name__)


def allowed_file(filename):
    return '.' in filename and  filename.rsplit('.', 1)[1] in app.config['ALLOWED_EXTENSIONS']


@upload.route('/', methods=['POST', 'GET'])
def upload_file():
    if request.method == 'POST':
        f = request.files['file']
        upload_path = os.path.join(app.config['UPLOAD_FOLDER'],secure_filename(f.filename))  #注意:没有的文件夹一定要先创建,不然会提示没有该路径
        f.save(upload_path)
        img = cv2.imread(upload_path)
        text=pytesseract.image_to_string(img)
        print(text)
    return jsonify({"status": 200, "msg": "upload success","text": text})

if __name__ == '__main__':
    app.run(debug=True)
Пример #8
0
from www import app
from photolib import db, config


if __name__ == '__main__':
    db.connect(config.DB_PATH)
    app.run()



Пример #9
0
    app.jinja_env.filters['format_log'] = format_log

    def hash_name(s):
        a = s.replace("\\", "_").replace("/", "_")
        m = hashlib.sha1()
        m.update(a.encode())
        digest = m.digest()
        digest64 = binascii.b2a_hex(digest).decode()
        return digest64

    app.jinja_env.filters['hash_name'] = hash_name

    def tohtml_logurl(s):
        idx = s.find("?")
        if idx != -1:
            s = s[:idx]
        return s

    app.jinja_env.filters['tohtml_logurl'] = tohtml_logurl

    def format_date(d):
        # Example: 2015-04-14T16:05:07.000+0000
        return dateutil.parser.parse(d).strftime("%b %e, %Y")

    app.jinja_env.filters['date'] = format_date

    app.config["TEMPLATES_AUTO_RELOAD"] = True

    app.run(HOST, PORT, debug=False)
Пример #10
0
        PORT = 5555

    #with app.app_context():
        #tests = g.get('tests', None)
        #g.setdefault('failed_tests', failed_tests)

    def format_log(s):
        return s.replace("\n", "<br/>")
    app.jinja_env.filters['format_log'] = format_log

    def hash_name(s):
        a = s.replace("\\", "_").replace("/", "_")
        m = hashlib.sha1()
        m.update(a)
        digest = m.digest()
        digest64 = binascii.b2a_hex(digest)
        return digest64

    app.jinja_env.filters['hash_name'] = hash_name

    def tohtml_logurl(s):
        idx = s.find("?")
        if idx != -1:
            s = s[:idx]
        return s

    app.jinja_env.filters['tohtml_logurl'] = tohtml_logurl


    app.run(HOST, PORT, debug=True)
Пример #11
0
from www import app
app.run(debug=True, use_reloader=False)
Пример #12
0
# coding: utf-8

from __future__ import division, print_function

__author__ = "adrn <*****@*****.**>"

# Standard library
import os, sys

# Project
from www import app

if __name__ == "__main__":
    from argparse import ArgumentParser

    # Define parser object
    parser = ArgumentParser(description="")
    parser.add_argument("--debug", action="store_true", dest="debug",
                        default=False, help="Run flask with debugging.")
    parser.add_argument("--extern", action="store_true", dest="extern",
                        default=False, help="Run on an external server")

    args = parser.parse_args()

    if args.extern:
        host = "0.0.0.0"
    else:
        host = "127.0.0.1"
    app.run(host=host, debug=args.debug)
Пример #13
0
def init(loop):
    app.run(debug=True)
Пример #14
0
#!./venv/bin/python3

from www import app
app.run()
Пример #15
0
    api.add_resource(SignUp, '/signup')
    api.add_resource(Login, '/login')
    api.add_resource(BusinessProfile, '/businesses/<string:bid>')
    api.add_resource(CheckIn, '/businesses/<string:bid>/checkins')
    api.add_resource(Users, '/users')
    api.add_resource(User, '/users/<string:user_id>')
    api.add_resource(UsersCheckin, '/users/<string:user_id>/checkins')
    api.add_resource(BusinessCategory, '/businesses/categories')
    api.add_resource(BusinessSurveyResults, '/businesses/<string:bid>/surveys')
    api.add_resource(BusinessSurveyResult, '/businesses/<string:bid>/surveys/<string:survey_id>')
    api.add_resource(BusinessSurveyTemplates, '/businesses/<string:bid>/survey_templates')
    api.add_resource(BusinessSurveyTemplate, '/businesses/<string:bid>/survey_templates/<string:survey_id>')
    api.add_resource(BusinessMessages, '/businesses/<string:bid>/messages')
    api.add_resource(BusinessMessage, '/businesses/<string:bid>/messages/<string:mid>')
    api.add_resource(BusinessReviews, '/businesses/<string:bid>/reviews')
    api.add_resource(BusinessReview, '/businesses/<string:bid>/reviews/<string:rid>')
    api.add_resource(Businesses, '/businesses')
    api.add_resource(BusinessAdmins, '/businesses/<string:bid>/admins')
    api.add_resource(BusinessAdmin, '/businesses/<string:bid>/admins/<string:admin_uid>')
    api.add_resource(BusinessPromotions, '/businesses/<string:bid>/promotions')
    api.add_resource(BusinessPromotion, '/businesses/<string:bid>/promotions/<string:pid>')
    api.add_resource(EligiblePromotions, '/businesses/<string:bid>/promotions/eligible_for_me')
    api.add_resource(PromotionApply, '/businesses/<string:bid>/promotions/<string:pid>/apply')

    api.add_resource(BusinessFollowers, '/businesses/<string:bid>/followers')

if __name__ == '__main__':
    initialize_app()
    app.run(host='0.0.0.0', debug=True, use_reloader=False)
Пример #16
0
from www import app

HOST = 'localhost'   # This restricts incoming calls to the local machine
#HOST = '0.0.0.0'     # This allows incoming calls from outside the machine (Windows will ask for Firewall permission)
PORT = 7882          # Arbitrary port (epoch accessible from outside)

import platform
hostname = platform.uname()[1]

print "HOSTNAME = %s" % hostname

# Better default choice than True
debug=False
if hostname.endswith('herald') :
    debug=True

## http://blog.rootsmith.ca/uncategorized/request-server-or-hostname-must-match-flasks-server_name-to-route-successfully/
#import os
#if 'SERVER_NAME' in os.environ:
#    print os.environ['SERVER_NAME']

app.run(host=HOST, port=PORT, debug=debug, )
Пример #17
0
from www import app

if __name__ == '__main__':
    app.run(host="0.0.0.0", port=80)
Пример #18
0
from www import app
import os

os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = 'true'
os.environ['DEBUG'] = 'true'
app.run(host="0.0.0.0", port=int(os.environ['PORT']), debug=True)
Пример #19
0
# -*- coding: utf-8 -*-
'''项目启动入口

'''
__author__ = 'zzy'

from flask_cors import CORS
from www import app

import os
from omr.shell import Shell

basepath = os.path.dirname(__file__)  # 当前文件所在路径
vue_dir = basepath + '/www/templates/vueweb'
cmd1 = "cd " + vue_dir
cmd2 = 'npm run build'
cmd3 = 'npm run dev'
cmd = cmd1 + ' && ' + cmd2 + ' && ' + cmd3
print('run this command in shell to start vue quickly:')
print(cmd)
print()

CORS(app, supports_credentials=True)
app.debug = True  #交互式调试器 WARNING: Do not use the development server in a production environment.
app.run(host='0.0.0.0')
Пример #20
0
from www import app

app.run(debug=True)
Пример #21
0
from www import app
app.run(host='0.0.0.0')