-
-
Notifications
You must be signed in to change notification settings - Fork 2
Quick Start
lethanhphuc edited this page Aug 7, 2023
·
1 revision
from flask import Flask, request
from gemini_self_protector import GeminiManager
app = Flask(__name__)
gemini = GeminiManager()
from flask import Flask, request
from gemini_self_protector import GeminiManager
app = Flask(__name__)
gemini = GeminiManager(app)
With the basic usage, Gemini runs in the default mode of "monitoring" and allows a sensitivity level of under 50, above which requests will be stored for monitoring purposes.
from flask import Flask, request, jsonify
from gemini_self_protector import GeminiManager
app = Flask(__name__)
gemini = GeminiManager(app)
@app.route('/api/login', methods=['POST'])
@gemini.flask_protect_extended() <--- Declare gemini below flask route and without option
def login():
username = request.json['username']
password = request.json['password']
if username == "test" and password == "test":
response = jsonify({
"status": "Success",
"message": "Login successful",
"access_token": access_token
})
return response
else:
return jsonify({
"status": "Fail",
"message": "Incorrect Username or Password"
}), 401
if __name__ == "__main__":
app.run()
The advanced usage of Gemini allows for deeper customization. Specifically, it is possible to specify individual modes for each router and have a dashboard to monitor the activity of the application. The running mode and sensitivity can be adjusted directly on the dashboard, and additional features are currently being developed.
from flask import Flask
from flask import jsonify
from flask import request
from gemini_self_protector import GeminiManager
app = Flask(__name__)
gemini = GeminiManager(app)
@app.route('/api/login', methods=['POST'])
@gemini.flask_protect_extended(protect_mode='block') <--- Declare gemini below flask route with protect mode option
def login():
username = request.json['username']
password = request.json['password']
if username == "test" and password == "test":
response = jsonify({
"status": "Success",
"message": "Login successful",
"access_token": access_token
})
return response
else:
return jsonify({
"status": "Fail",
"message": "Incorrect Username or Password"
}), 401
if __name__ == "__main__":
app.run()