-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
38 lines (30 loc) · 1016 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from flask import Flask, render_template, jsonify, send_from_directory
from flasgger import Swagger, swag_from
from api.kismet_api import KismetAPI
import json
import random
import os
app = Flask(__name__)
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0 # Disable caching for development
kismet_api = KismetAPI()
swagger = Swagger(app)
app.config['SWAGGER'] = {
'title': 'Kismet Fortune Telling API',
'uiversion': 3,
'hide_top_bar': True,
'specs_route': '/api/swagger/',
}
@app.route('/static/<path:filename>')
def serve_static(filename):
root_dir = os.path.dirname(os.getcwd()) # Adjust this path if needed
return send_from_directory(os.path.join(root_dir, 'static'), filename)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/api/fortune', methods=['POST'])
@swag_from('kismet.yml')
def fortune():
fortune_result = kismet_api.get_random_fortune()
return jsonify({'fortune': fortune_result})
if __name__ == '__main__':
app.run(debug=True)