2017-12-12 18:51:16 +01:00
|
|
|
from flask import Flask, jsonify, abort, send_from_directory
|
2016-11-08 15:00:15 +01:00
|
|
|
|
|
|
|
import generate
|
2017-12-10 15:13:33 +01:00
|
|
|
import ikeagen
|
|
|
|
|
2017-12-12 18:51:48 +01:00
|
|
|
app = Flask(__name__)
|
2016-11-08 15:00:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
@app.route('/api/description/<int:count>/')
|
|
|
|
def get_description(count):
|
|
|
|
descriptions = []
|
2016-11-08 15:05:21 +01:00
|
|
|
if count > 1000:
|
2016-11-08 15:00:15 +01:00
|
|
|
abort(422)
|
|
|
|
for _ in range(count):
|
2017-12-10 15:13:33 +01:00
|
|
|
descriptions.append({
|
|
|
|
"description": generate.get_description(),
|
|
|
|
"name": ikeagen.generate()
|
|
|
|
})
|
|
|
|
response = jsonify(descriptions)
|
|
|
|
return response
|
2016-11-08 15:00:15 +01:00
|
|
|
|
|
|
|
|
2017-12-12 18:51:16 +01:00
|
|
|
if __name__ == "__main__":
|
|
|
|
@app.route('/<path:path>')
|
|
|
|
def send_js(path):
|
|
|
|
return send_from_directory('public', path)
|
2016-11-08 15:00:15 +01:00
|
|
|
|
|
|
|
|
2017-12-12 18:51:16 +01:00
|
|
|
app.run()
|