|
| 1 | +from flask import Flask, jsonify, request |
| 2 | +from mimesis.schema import Field, Schema |
| 3 | +from mimesis.enums import Gender |
| 4 | + |
| 5 | +app = Flask(__name__) |
| 6 | + |
| 7 | +_ = Field('zh') |
| 8 | +schema = Schema(schema=lambda: { |
| 9 | + 'id': _('uuid'), |
| 10 | + 'name': _('person.name'), |
| 11 | + 'version': _('version', pre_release=True), |
| 12 | + 'timestamp': _('timestamp', posix=False), |
| 13 | + 'owner': { |
| 14 | + 'email': _('person.email', domains=['test.com'], key=str.lower), |
| 15 | + 'token': _('token_hex'), |
| 16 | + 'creator': _('full_name', gender=Gender.FEMALE) |
| 17 | + }, |
| 18 | + 'address': { |
| 19 | + 'country': _('address.country'), |
| 20 | + 'province': _('address.province'), |
| 21 | + 'city': _('address.city') |
| 22 | + } |
| 23 | +}) |
| 24 | + |
| 25 | + |
| 26 | +@app.route('/apps', methods=('GET',)) |
| 27 | +def apps_view(): |
| 28 | + count = request.args.get('count', default=1, type=int) |
| 29 | + data = schema.create(iterations=count) |
| 30 | + return jsonify(data) |
| 31 | + |
| 32 | + |
| 33 | +if __name__ == '__main__': |
| 34 | + app.run(host='127.0.0.1', port=5200, debug=True) |
0 commit comments