Example #1
0
def runApp():
    app.run(debug=True)
Example #2
0
#!env/bin/python
from db import app

app.run(debug=False, host='0.0.0.0', port="1234")
Example #3
0
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.

# Use a breakpoint in the code line below to debug your script.
# Press Ctrl+F8 to toggle the breakpoint.

# Press the green button in the gutter to run the script.
from jenkins.apijenkins import TaskApi
from login.login import Login
from flask_restful import Api
from db import app
from login.report import TestReportApi
from login.testcaseApi import TestCaseApi
from flask_cors import CORS
from login.assertstatus import AssertStatus
from flask_restful import Resource
api = Api(app)
CORS(app)

api.add_resource(Login, '/login')
# api.add_resource(SevenirubyUser11,'/db')
api.add_resource(TaskApi, '/task')
api.add_resource(TestCaseApi, '/testcase')
api.add_resource(TestReportApi, '/report')
api.add_resource(AssertStatus, '/status')
if __name__ == '__main__':
    app.run(debug=True)

# See PyCharm help at https://www.jetbrains.com/help/pycharm/
Example #4
0
            if not found:
                restModelDict["context"] = "Category: " + catModel["context"]
                restDataList.append(restModelDict)

    catAndRestList = []
    catAndRestIndex = 0;

    for locModel in locDataList:
        restModelDict = getDataDict(Restaurant.query.filter_by(location_id = locModel["id"]).one())
        found = False
        currRestModel = None
        for restModel in restDataList:
            if(str(restModel["id"]) == str(restModelDict["id"])):
                catAndRestList.append(restModel)
                restDataList.remove(restModel)
        if len(catAndRestList) == (catAndRestIndex+1):
            if("Location" not in catAndRestList[catAndRestIndex]):
                catAndRestList[catAndRestIndex]["context"] += ", Location: " + locModel["context"]
                catAndRestIndex += 1
        else:
            restModelDict["context"] = "Location: " + locModel["context"]
            restDataList.append(restModelDict)

    for catAndRest in catAndRestList:
        restDataList.insert(0, catAndRest)


if __name__ == '__main__':
    app.debug = True # Comment out for production
    app.run(host='127.0.0.1')
Example #5
0
# Edits on an item from the Grocery List.
@app.route("/v1/groceries", methods=["PUT"])
def put_gaitems():
    if request.mimetype == 'application/json':
        eventid_queryparam = request.args.get('ID')
        new_item = json_body('name')
        item_created_by = request.headers['userID']
        cursor_request(
            """UPDATE Grocery_List
            SET name=%s,lastEditedBy=%s WHERE ID=%s""",
            (new_item, item_created_by, eventid_queryparam))
        return jsonify(new_item, eventid_queryparam, item_created_by), 200
    return "No item has been edited", 500


# Retreives all grocery list from the Users.
@app.route("/v1/users", methods=["GET"])
def single_item():
    userid_queryparam = request.args.get('userID')
    if request.mimetype == 'application/json':
        user_items = fetchall_cursor("""SELECT *
                                  FROM Grocery_List
                                  WHERE userID='%s'""" % (userid_queryparam))
        return user_items
    return "No item has been found", 500


#server
if __name__ == "__main__":
    app.run(debug=True, host='0.0.0.0')
Example #6
0
    }

@celery.task
def cache_dataset_task(dataset_name):
    print('cache_dataset_task_id')
    with app.app_context():
        return pipeline.cache_dataset(dataset_name)

@celery.task
def populate_database_task():
    print('populate_database_task_id')
    with app.app_context():
        return pipeline.game.populate_database()
    
if __name__ == '__main__':
    app.run(debug=True, threaded=True)


# @app.route('/get-dashboard-data/<dashboard_name>')
# def get_dashboard_data(dashboard_name):
#     table_name = dashboard_name.replace('-', '_')
#     sql = psycopg2.sql.SQL('select * from {}').format(psycopg2.sql.Identifier(table_name))
#     with db.app.get_connection() as connection:
#         df = db.app.query_database(connection, sql)
#     if 'date' in df.columns:
#         df['date'] = pd.to_datetime(df['date']).dt.strftime('%Y-%m-%d')
#     return utils.to_web_dict(df)

# @app.route('/populate-dashboard-data/<dashboard_name>')
# def populate_dashboard_data(dashboard_name):
#     table_name = dashboard_name.replace('-', '_')
Example #7
0
File: run.py Project: xiran2018/tfs
    notfilterURL = ["/user/loginHtml", "/user/login"]
    if requestPath.find("static") > -1:  #说明是静态文件
        pass
    # print("===============请求地址:" + str(request.path))
    elif requestPath in notfilterURL:
        # print("===============不需要过滤")
        pass
    else:
        if 'userId' in session and 'type' in session:
            # print('已登录')
            pass
        else:
            # print('未登录,要跳转到登录页面')
            return redirect("/user/loginHtml")

    # print("请求地址:" + str(request.path))
    # print("请求方法:" + str(request.method))
    # print("---请求headers--start--")
    # print(str(request.headers).rstrip())
    # print("---请求headers--end----")
    # print("GET参数:" + str(request.args))
    # print("POST参数:" + str(request.form))


app.register_blueprint(admin, url_prefix='/admin')
app.register_blueprint(user, url_prefix='/user')
app.register_blueprint(company, url_prefix='/p')

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8088, debug=True)
Example #8
0
        
        if int(request.form['age']) <= app.config['AGE']:
            error = 'Invalid age'
        elif not profiles:
            error = 'Invalid username'
        else:
            session['logged_in'] = True
            flash('You were logged in')
            return redirect(url_for('index'))
    return render_template('login.html', error=error)

@app.route('/logout')
def logout():
    session.pop('logged_in', None)
    flash('You were logged out')
    return redirect(url_for('index'))

if __name__ == '__main__':
    #app.run(debug=True)
     # To allow aptana to receive errors, set use_debugger=False
    app = create_app(config="config.yaml")

    if app.debug: use_debugger = True
    try:
        # Disable Flask's debugger if external debugger is requested
        use_debugger = not(app.config.get('DEBUG_WITH_APTANA'))
    except:
        pass
    app.run(use_debugger=use_debugger, debug=app.debug,
            use_reloader=use_debugger, host='0.0.0.0')
Example #9
0
                    'answers': answers
                }
            })
    else:
        answers = db_helper.get_all_answers(int(args.get('task_id')))
        return str({'error': 0, "data": {'msg': '获取成功', 'answers': answers}})


@app.route("/initial/", methods=['GET'])
def initial_():
    '''初始化数据库
	'''
    try:
        stus, orgs = db_helper.initial_data()
        return str({
            'error': 0,
            'data': {
                'stus': str(stus),
                'orgs': str(orgs)
            }
        })
    except Exception:
        return str({'error': 1})


if __name__ == "__main__":
    uploaded_photos = UploadSet('photos')
    configure_uploads(app, uploaded_photos)
    enter_event_and_run_scheduler()
    app.run(debug=True, use_reloader=False)
Example #10
0
from resources.qa_delay_statistics import QADelayStatistics
from resources.qa_bug_severity_rate_statistics import QABugSeverityRateStatistics
from resources.qa_bug_invalid_rate_statistics import QABugInvalidRateStatistics

api = Api(app)

api.add_resource(Login, '/zentao/login')
api.add_resource(User, '/zentao/user', '/qms/user')  # /qms/user给QA系统用
api.add_resource(QaUser, '/zentao/qa_user')  # /qms/user给QA系统用
api.add_resource(UserList, '/zentao/userlist')
api.add_resource(Product, '/zentao/product')
api.add_resource(TestTask, '/zentao/testtask')
api.add_resource(Story, '/zentao/story')
api.add_resource(TestStory, '/zentao/teststory')
api.add_resource(Task, '/zentao/task')
api.add_resource(Bug, '/zentao/bug')
api.add_resource(Project, '/zentao/project')
api.add_resource(ProjectStatistics, '/zentao/project_statistics')

api.add_resource(QADelayStatistics, '/zentao/qa_delay_statistics')
api.add_resource(QABugSeverityRateStatistics, '/zentao/qa_severity_statistics')
api.add_resource(QABugInvalidRateStatistics, '/zentao/qa_invalid_statistics')

api.add_resource(QaTaskType, '/qms/tasktype')
api.add_resource(QaTask, '/qms/task')
api.add_resource(QaTestTask, '/qms/testtask')


if __name__ == '__main__':
	app.run(debug=True, host='0.0.0.0', port=8089, threaded=True)  # processes 进程参数
Example #11
0
from ressources.register import Register
from ressources.send_files import Send
from ressources.manage_file import Manage
from ressources.unregister import Unregister
from db import recreate_database, create_app
from db import app, api

# api.add_resource(Queue, '/')
api.add_resource(Register, '/register')
api.add_resource(Send, '/send')
api.add_resource(Manage, '/manage')
api.add_resource(Unregister, '/unregister')

if __name__ == '__main__':
    create_app()
    recreate_database()
    app.run(host='0.0.0.0', port=5001)
Example #12
0
api.add_resource(Rule, '/rule/<string:id>', '/rule')
api.add_resource(Subscriber, '/subscriber/<string:id>', '/subscriber')
api.add_resource(Workflow, '/workflow/<string:id>', '/workflow')
api.add_resource(Eval, '/eval/<string:id>', '/eval')
api.add_resource(Link, '/link/<string:id>', '/link')
api.add_resource(Login, '/login')
api.add_resource(ComplianceReport, '/compliance_report',
                 '/compliance_report/<string:id>')
api.add_resource(ComplianceElement, '/compliance_element',
                 '/compliance_element/<string:id>')
api.add_resource(ComplianceExecution, '/compliance_execution',
                 '/compliance_execution/<string:id>')
api.add_resource(Check, '/check', '/check/<string:id>')
api.add_resource(CheckResult, '/check_result', '/check_result/<string:id>')
api.add_resource(JobTemplate, '/job_template', '/job_template/<string:id>')

if __name__ == '__main__':
    handler = RotatingFileHandler(OPTIMA_BACKEND_API_LOGFILE,
                                  maxBytes=10000,
                                  backupCount=1)
    handler.setLevel(logging.DEBUG)
    log = logging.getLogger('werkzeug')
    log.setLevel(logging.DEBUG)
    log.addHandler(handler)
    from db import db
    db.init_app(app)
    app.run(host='0.0.0.0',
            port=parser.getint('API_SECTION', 'API_PORT'),
            debug=True,
            threaded=True)
Example #13
0
@app.route('/presentations/<presentation_id>/delete', methods=["GET"])
@login_required
@instructor_required
def delete_presentation(presentation_id):
    presentation = Presentation.query.get(presentation_id)
    db.session.delete(presentation)
    db.session.commit()
    return redirect(
        url_for('list_presentations', course_id=presentation.course_id))


uploads = Blueprint('uploads', __name__, url_prefix='/uploads')


@uploads.route('/<setname>/<path:filename>')
@login_required
def show(setname, filename):
    config = current_app.upload_set_config.get(setname)
    if config is None:
        abort(404)
    if g.user.has_permission_to_read(setname, filename):
        return send_from_directory(config.destination, filename)
    else:
        abort(403)


app.register_blueprint(uploads)

if __name__ == '__main__':
    app.run('0.0.0.0', debug=True, ssl_context='adhoc')
Example #14
0
import os

from flask import render_template

from db import app
from db import db

from db_loader import build_sample_db


# Flask views
@app.route('/')
def index():
    return render_template('index.html')

if __name__ == '__main__':

    # Build a sample db on the fly, if one does not exist yet.
    app_dir = os.path.realpath(os.path.dirname(__file__))
    database_path = os.path.join(app_dir, app.config['DATABASE_FILE'])
    if not os.path.exists(database_path):
        build_sample_db(app, db)

    # Start app
    app.run(debug=app.config['DEBUG'])
Example #15
0
from flask_restful import Api

from resources import KijijiAdSearch, SavedCars, SavedCarsList, SavedSearches, SavedSearchesList
from db import app, db
api = Api(app)

api.add_resource(KijijiAdSearch, '/cars/')
api.add_resource(SavedSearchesList, '/saved-search/')
api.add_resource(SavedSearches, '/saved-search/<int:save_id>')
api.add_resource(SavedCarsList, '/saved-car/')
api.add_resource(SavedCars, '/saved-car/<int:save_id>')


@app.after_request
def after_request(response):
    response.headers.add('Access-Control-Allow-Origin', '*')

    response.headers.add('Access-Control-Allow-Headers',
                         'Content-Type,Authorization')
    response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE')
    return response


if __name__ == '__main__':
    app.run(host='127.0.0.1', port='5000')
Example #16
0
        return error_handler("Need json data or Wrong format", 404)
    res = dh.getSaleRecord(json['start'], json.get('end', None), orderby_date)
    if not isinstance(res, list):
        return error_handler(res, 404)
    result = []
    for r in res:
        item = None
        for it in result:
            if it['id'] == r[0]:
                item = it
                break
        if not item:
            item = {'id': r[0],
                    'date': str(r[1]),
                    'discount': float(r[2]),
                    'detail': [
                {
                    'prod_id': r[5], 'num': r[3], 'price': float(r[4])
                }
            ]}
        else:
            item['detail'].append(
                {'prod_id': r[5], 'num': r[3], 'price': float(r[4])})
        result.append(item)
    return jsonify({'sale_list': result})

# end--------------------交易记录相关API--------------------

if __name__ == '__main__':
    app.run(host=ch.server.ip, port=ch.server.port, debug=ch.debug)
Example #17
0

@app.route('/data/read', methods=['GET'])
def dataRead():
    # print(request.args.to_dict()) # 可獲得query_parameters
    return {"status": 200, "result": []}


@app.route('/data/update', methods=['UPDATE'])
def dataUpdate():
    pass
    return {"status": 200, "result": []}


@app.route('/data/delete', methods=['DELETE'])
def dataDelete():
    pass
    # request.args.to_dict() # 可獲得query_parameters
    return {"status": 200, "result": ""}


if __name__ == "__main__":
    app.run(host="localhost", port=5002, debug=True)
"""sqlite operate
conn = sqlite3.connect('example.db')
cursor = conn.cursor()
res = cursor.execute().fetchall() # return list



"""
Example #18
0
from flask import Response, jsonify, request

from models.AdminModel import AdminModel
from views.Auth import requires_auth

from db import app, db
import views

# Register sub views.

app.register_blueprint(views.Heartbeat.bp)
app.register_blueprint(views.Kiosk.bp)
app.register_blueprint(views.Parent.bp)
app.register_blueprint(views.Child.bp)
app.register_blueprint(views.Entry.bp)
app.register_blueprint(views.Admin.bp)


@app.route('/login')
@requires_auth
def login():
    auth = request.authorization
    admin = db.session.query(AdminModel).filter_by(email=auth.username).first()
    return jsonify(admin.as_dict())


if __name__ == '__main__':
    app.run()
Example #19
0

@app.route('/presentations/<presentation_id>/delete', methods=["GET"])
@login_required
@instructor_required
def delete_presentation(presentation_id):
    presentation = Presentation.query.get(presentation_id)
    db.session.delete(presentation)
    db.session.commit()
    return redirect(
        url_for('list_presentations', course_id=presentation.course_id))


uploads = Blueprint('uploads', __name__, url_prefix='/uploads')

@uploads.route('/<setname>/<path:filename>')
@login_required
def show(setname, filename):
    config = current_app.upload_set_config.get(setname)
    if config is None:
        abort(404)
    if g.user.has_permission_to_read(setname, filename):
        return send_from_directory(config.destination, filename)
    else:
        abort(403)
app.register_blueprint(uploads)


if __name__ == '__main__':
    app.run('0.0.0.0', debug=True, ssl_context='adhoc')
Example #20
0
    country = geolocator.reverse(geolocation, language ='en', timeout = 60)
    country = country.address.split(',')
    return country[-1].strip(' ')

def parseCname(cname):
    if cname == 'Congo-Kinshasa':
        cname = 'Democratic Republic of the Congo'
    elif cname == 'Czechia':
        cname = 'Czech Republic'
    elif cname == 'United States of America':
        cname = 'United States'
    elif cname == 'Russian Federation':
        cname = 'Russia'
    elif cname == 'RSA':
        cname = 'South Africa'
    elif cname == 'The Netherlands':
        cname = 'Netherlands'
    elif cname == 'Islamic Republic of Iran':
        cname = 'Iran'
    return cname

@manager.command
def create_db():
    #logger.debug("create_db")
    app.config['SQLALCHEMY_ECHO'] = True
    createdb()

if __name__ == '__main__':
    manager.run()
    app.run(debug=True)
Example #21
0
    linksOr, titlesOr, contextsOr = searchTermOr(query)
    return render_template("search_multiple.html", term = query, titlesAnd = titlesAnd, linksAnd = linksAnd, contextsAnd = contextsAnd, titlesOr = titlesOr, linksOr = linksOr, contextsOr = contextsOr)

@app.errorhandler(404)
def error_404(error):
    return render_template('error.html'), 404

@app.route("/error")
def error():
    return render_template('error.html')

@app.route("/searchURL/", methods=['POST'])
def URLsearch():
    url = request.form['search']
    return redirect('/search/' + url)

@app.route("/musicapi/")
def musicapi():
    f = open("musicapi.out", 'r')
    val = ""
    for line in f:
        result = line.split(' ')
        val += result[1] + " " +  result[0] + "|"
    f.close()
    jsonVal = json.dumps(val)

    return render_template('musicapi.html', val = str(jsonVal));

if __name__ == "__main__":
    app.run(host='0.0.0.0', port=5000)