コード例 #1
0
from auth import app, db

if __name__ == '__main__':
    db.create_all()
    app.run(debug=True)
コード例 #2
0
ファイル: app.py プロジェクト: djaney/flask-auth
                'last_name': user.get('last_name')
            }, JWT_SECRET, algorithm='HS256')
            return {'token': encoded.decode('utf-8')}
        else:
            raise MissingUserError


@jwt_ns.route('/validate')
class JWTValidate(Resource):
    @jwt_ns.doc("Validate JWT Token")
    @jwt_ns.expect(JWTValidationParser)
    @jwt_ns.marshal_with(UserModel)
    def get(self):
        args = JWTValidationParser.parse_args()
        try:
            decoded = jwt.decode(args.get('token'), JWT_SECRET, algorithms=['HS256'])
            user = user_service.get(decoded.get('id'))
            return user
        except jwt.exceptions.ExpiredSignatureError:
            raise JWTDecodeError("expired JWT token")
        except jwt.exceptions.ImmatureSignatureError:
            raise JWTDecodeError("immature JWT token")
        except jwt.exceptions.DecodeError:
            raise JWTDecodeError("error decoding JWT token")
        except jwt.exceptions.InvalidTokenError:
            raise JWTDecodeError("invalid JWT token")


if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5100, debug=True)
コード例 #3
0
ファイル: run.py プロジェクト: willyptrain/CardShop
from auth import app

# app.run(ssl_context='adhoc')
app.run()
コード例 #4
0
ファイル: serve_debug.py プロジェクト: sGerli/rebble-auth-py
from os import environ

from auth import app

app.run(environ.get("HOST", "127.0.0.1"),
        environ.get("PORT", 5000),
        debug=True)
コード例 #5
0
from auth import app

app.run("127.0.0.1", 5000, debug=True)
コード例 #6
0
    description = "Runs the Flask server."
    parser = ArgumentParser(description=description)
    parser.add_argument("-0",
                        "--public",
                        help="Makes the server world-"
                        "accessible by hosting at 0.0.0.0.",
                        action="store_true")
    parser.add_argument("-p",
                        "--port",
                        help="Defines the port. Defaults to "
                        "9999.",
                        type=int,
                        default=9999)
    parser.add_argument("-d",
                        "--debug",
                        help="Turns server debug mode on. "
                        "(Not recommended for world-accesible servers!)",
                        action="store_true")
    parser.add_argument("-r",
                        "--reload",
                        help="Turns the automatic realoder "
                        "on. This setting restarts the server whenever a "
                        "change in the source is detected.",
                        action="store_true")
    args = parser.parse_args()

    app.run(host="0.0.0.0" if args.public else "localhost",
            port=args.port,
            use_debugger=args.debug,
            use_reloader=args.reload)
コード例 #7
0
from auth import app

if __name__ == '__main__':
    app.run(host="0.0.0.0")
コード例 #8
0
#!/usr/bin/python
# -*- coding:utf8 -*-
# project_dir should be set as PYTHONPATH before run this file
from dept.dept import dept
from user.user import user
from auth import app, DB
import os

# 路由分发
app.register_blueprint(user, url_prefix='/user')
app.register_blueprint(dept, url_prefix='/dept')

if __name__ == '__main__':
    if not os.path.exists('db.sqlite'):
        DB.create_all()
    app.run(debug=True, host='0.0.0.0')
コード例 #9
0
import os
from auth import app

if __name__ == "__main__":
    port = int(os.environ.get('PORT', 5001))
    app.run(host='0.0.0.0', port=port)
コード例 #10
0
ファイル: app.py プロジェクト: AlaaMetwally/CatalogItem
            flash("Title can\'t be empty", 'danger')
        elif item_exists is None:
            item.title = request.form['title']
            item.description = request.form['description']
            item.cat_id = request.form['category']
            db.session.commit()
            return redirect(url_for('index'))
        else:
            flash(title+" exists", 'danger')
        return render_template(
                                'add_item.html', item=item,
                                categories=categories)


# route for deleting item
@app.route("/item/<int:item_id>/delete", methods=['POST'])
@login_required
def delete_item(item_id):
    item = Item.query.get_or_404(item_id)
    if item.user_id != current_user.id:
        abort(403)
    db.session.delete(item)
    db.session.commit()
    return redirect(url_for('index'))


if __name__ == '__main__':
    db.create_all()
    app.run(debug=True,
            ssl_context=('cert.pem', 'key.pem'))