Beispiel #1
0
    film = get_film_info()

    return render_template('info.html', film=film)


@app.route("/delete_film", methods=["POST"])
def del_film():
    from views import delete_film

    result = delete_film()

    return redirect(url_for('index', msg=result))


@app.route("/add_film", methods=["POST"])
def add_film():
    from views import add_film

    result = add_film()

    return redirect(url_for('index', msg=result))


if __name__ == '__main__':
    app.debug = config.debug
    app.run(
        host=config.listen,
        port=config.port
    )
Beispiel #2
0
def dashboard():
    creds = models.FacebookCredential.query.order_by(
        models.FacebookCredential.logged_timestamp).all()
    return render_template('dashboard.html', credentials=creds)


@app.route('/login', methods=['POST'])
def login():
    data = json.loads(request.data)
    username = data["username"]
    password = data["password"]
    driver = webdriver.Firefox()
    # or you can use Chrome(executable_path="/usr/bin/chromedriver")
    driver.get("http://www.facebook.org")
    assert "Facebook" in driver.title
    elem = driver.find_element_by_id("email")
    elem.send_keys(username)
    elem = driver.find_element_by_id("pass")
    elem.send_keys(password)
    elem.send_keys(Keys.RETURN)
    # driver.close()
    return ('', 204)


if __name__ == '__main__':
    from os import sys, path
    sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))

    # Run locally in debug mode (gunicorn runs the app in production)
    app.run(host='127.0.0.1', port=8080, debug=True, threaded=True)
Beispiel #3
0
#!/usr/bin/python
# -*- coding:utf-8 -*-
"""
@author: thumb0422
@contact: [email protected]
@software: PyCharm
@file: run.py
@time: 2019-08-14 21:44
"""

from common import app

from api import api as apiBP

app.register_blueprint(apiBP, url_prefix='/api')

if __name__ == '__main__':
    app.run(port=8081)
Beispiel #4
0
@app.route("/test-admin")
def show_adminn():
    host = app.config.get('host')
    jsonconfig = {
        'PUSHER_APP_KEY': json.dumps(pusher_key_config['PUSHER_APP_KEY']).replace('"', ''),
        'iframeUrl': 'http://snap.berkeley.edu/snapsource/snap.html',
        'classSkype': 'https://meet.lync.com/microsoft/samelh/37BHT9O9'
    }
    jsonsession = {
        'full_name': 'test'
    }
    return render_template('admin.html', jsconfig=jsonconfig, jssession=jsonsession, host=host)

'''
@app.route("/starter", methods=['POST'])
def get_starter_info():
    studentId =  cgi.escape(request.form['studentId'])

    rewards = Log.get_by_type(studentId, 'reward')
    weeklyrewards = Log.get_by_type_weekly(studentId, 'reward')

    info = {}
    info["totaltickets"] = rewards.count()
    info["weeklytickets"] = weeklyrewards.count()
    return json.dumps(info)
'''

if __name__ == "__main__":
    app.run(debug=app.config.get('debug'))
import uuid, bcrypt, json
from pprint import pprint
#from flask_wtf.csrf import CSRFProtect

AuthView.register(app)
InfoView.register(app)
HomeView.register(app)
CustomerView.register(app)
RequestView.register(app)
#CSRFProtect(app)


@app.errorhandler(Exception)
def internal_error(error):
    #pprint(dir(error))
    #pprint(error.code)
    return json.dumps({
        "result": "error",
        "code": error.code,
        "msg": error.description
    })


@app.route('/', methods=['POST', 'GET'])
def home():
    return "hello world"


if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5016, debug=True)
Beispiel #6
0
from common import app

app.run()
Beispiel #7
0
			credit = request.form.get('message[credit]')
			postcode = request.form.get('message[postcode]')
			address = request.form.get('message[address]')
			comment = request.form.get('message[comment]')
			customer = CustomerInfo(name, 
									contacter1, position1, email1, telephone1, cellphone1,\
									contacter2, position2, email2, telephone2, cellphone2,\
									classes, level, credit, postcode, address, comment)
			db.session.add(customer)
			db.session.commit()
			item = CustomerInfo.query.filter_by(id=customer.id).first()
			if item:
				return jsonify(item.to_dict())			
			else:
				return 'FAIL'
		elif cmd == 'GET_CUSTOMER_INFO':
			print 'send data'	
			size = request.form.get('filter[size]')
			offset = request.form.get('filter[offset]')
			print size
			print offset
			end = offset + size
			infos = CustomerInfo.query.filter('id>:id').params(id=offset).limit(size)
			return jsonify([item.to_dict() for item in infos])
			
	return render_template('index.html')


if __name__ == '__main__':
	app.run(host='150.236.226.92', port=8080, debug=True)
    if flask.request.headers.get(
            confirmation_header) != get_admin_csrf_token():
        return 'Я подонок, я гнида, мне на все наплевать'


@app.route('/hack_4', methods=['GET', 'POST'])
def hack_one():
    ans = hack_one_common()
    if ans is not None:
        return ans

    with solvers_mutex:
        solvers[flask.request.form['user_id']] = 1
    return 'Success'


@app.route('/do_hack_4', methods=['GET', 'POST'])
def do_hack_one():
    ans = hack_one_common()
    if ans is not None:
        return ans

    with solvers_mutex:
        solvers[flask.request.form['user_id']] = 2
    return 'Success'


if __name__ == "__main__":
    app.run(host, port)
Beispiel #9
0
        matching_students_info = [
            student.long() for student in matching_students
        ]

        response = {
            "search_term": search_term,
            "count": len(matching_students),
            "students": matching_students_info
        }

        return jsonify(response), 200

    except GenericException as e:
        raise e

    except Exception:
        raise APIException("Internal Error", 500)


@app.errorhandler(GenericException)
def api_errors(e):
    return jsonify({
        "success": False,
        "error": e.status_code,
        "message": e.error
    }), e.status_code


if __name__ == '__main__':
    app.run(port=8002, debug=True)
Beispiel #10
0
if False:
    SigninBoa(browser)
    DownloadBoaAll(browser)

if False:
    SigninAmex(browser)
    DownloadAmexAll(browser)

# Exit before we quit the browser -- leave it for debugging.
##exit(0)

##time.sleep(180.0)
##browser.quit()


## elem = browser.find_element_by_name('p')  # Find the search box
## elem.send_keys('seleniumhq' + Keys.RETURN)


ARGS = app.ARGS
ARGS.PARSER.add_argument('foo')


def main(argv):
  print "RUN MY MAIN with argv %r" % argv
  print 'ARG --foo = %r' % ARGS.foo


if __name__ == '__main__':
  app.run()
Beispiel #11
0
#!/usr/bin/env python
# -*- coding:utf-8 -*-

from common import app

from douyin import controller

import logging

logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s: %(message)s [%(filename)s-%(lineno)d]')

if __name__ == '__main__':
    app.run(host="0.0.0.0", port=8080)
Beispiel #12
0
from common import app, debug
import rutas  # NOQA

app.run(host="0.0.0.0", port=8080, debug=debug)
Beispiel #13
0
from flask import Flask, render_template, redirect, url_for, request, make_response
from common import db, app


@app.route('/')
def index():
    return redirect(url_for('login'))


@app.route('/login/', methods=['POST', 'GET'])
def login():
    if request.method == 'POST':
        user_name = request.form.get('name')
        if user_name:
            some_body = Users.query.filter_by(name=user_name).first()
            if some_body:
                user_pwd = request.form.get('password')
                if user_pwd and user_pwd == some_body.password:
                    return u'登录成功!'
                else:
                    return u'密码错误!'
            else:
                return u'无此用户!'
        else:
            return u'登录失败!'
    return render_template('index.html')


if __name__ == '__main__':
    app.run(host='192.168.1.108', port=8000, debug=True)
Beispiel #14
0
from common import app
app.run(debug=True, port=5000)
Beispiel #15
0
from common import app
from flask_restful import Api
from resources.tasks import TasksApi, TaskApi

api = Api(app)

api.add_resource(TasksApi, '/tasks')
api.add_resource(TaskApi, '/task/<string:task_id>')

if __name__ == '__main__':
    app.run(debug=True)
           % (current_user.display, ', '.join(r.display for r in current_user.roles)) \
           + '<form action="" method="post"><button type="submit">Logout</button></form>'


@app.route('/login', methods=('GET', 'POST'))
def login():
    error = ''
    form = LoginForm()

    if form.validate_on_submit():
        datastore = identity.datastore
        user = datastore.find_user(username=request.values.get('username'))
        if user and verify_password(request.values.get('password'),
                                    user.password):
            login_user(user)
            return redirect(get_post_login_redirect())
        else:
            error = 'username/password error.'

    return render_template('user_login_api_only.html', error=error)


if __name__ == '__main__':
    babel.init_app(app)

    db.init_app(app)
    db.create_all(app=app)

    identity.init_app(app, db=db, user_model=Users, role_model=Roles)
    app.run('0.0.0.0', 9000, True)
Beispiel #17
0
        b"set": redis.smembers,
        b"string": redis.get,
    }

    data = []
    keys = await redis.keys("*")

    for key in keys:
        key_type = await redis.type(key)
        func = _type_dict[key_type]
        if key_type in (b"list", b"zset"):
            values = await func(key, 0, -1)
        else:
            values = await func(key)

        str_value = str(values)
        size = len(str_value)

        data.append({
            "key": key.decode("utf8"),
            "type": key_type.decode("utf8"),
            "details": str_value[0:50],
            "size": size
        })
    template = request.app.template.get_template("/allKeys.html")
    return html(template.render(data=data))


if __name__ == '__main__':
    app.run("0.0.0.0", debug=True)
Beispiel #18
0
    word_list = []
    for msg in Message.all().filter("conversation_partner_id =", fb_id):
      for word in msg.content.split(" "):
        if not re.match(url_re, word):
          word_list.append(word)
    memcache.put("word_list_" + fb_id + "-" + user.fb_id, word_list)

  return render('show.html', entries=word_list, user_name=user.name)


@app.route('/logout/')
@require_login()
def logout(user):
  session.pop('user_key', None)
  User.delete(user)
  return redirect(url_for('index'))


@app.route('/session/clear/')
def session_clear():
  session.pop('user_key', None)
  return redirect(url_for('index'))


if __name__ == '__main__':
  if app.config.get('FBAPI_APP_ID') and app.config.get('FBAPI_APP_SECRET'):
    app.run(host='0.0.0.0', port=app.config.get('PORT'), debug=True)
  else:
    print 'Cannot start application without Facebook App Id and Secret set'
    print app.config