feat: faker contacts
This commit is contained in:
33
app.py
33
app.py
@@ -3,14 +3,13 @@ import config
|
||||
import utils.response as response
|
||||
import service.faker_data as faker
|
||||
from base import db
|
||||
from model import Person, SexEnum, City
|
||||
from model import Person, SexEnum, City, Hotel
|
||||
from sqlalchemy import select, join
|
||||
|
||||
app = Flask(__name__)
|
||||
config.init_config(app)
|
||||
db.init_app(app)
|
||||
db.app = app
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
|
||||
|
||||
@app.route('/')
|
||||
def hello_world(): # put application's code here
|
||||
@@ -18,13 +17,27 @@ def hello_world(): # put application's code here
|
||||
return 'Hello World!'
|
||||
|
||||
|
||||
@app.route("/faker")
|
||||
def faker_data():
|
||||
# persons = faker.store_faker_identification(1)
|
||||
# results = [person.__to_dict__() for person in persons]
|
||||
# return response.succ(persons)
|
||||
return response.succ(faker.faker_railways(30))
|
||||
@app.route("/faker/railway/<number>")
|
||||
def faker_railway(number):
|
||||
return response.succ(faker.faker_railways(int(number)))
|
||||
|
||||
|
||||
@app.route("/faker/hotel/<number>")
|
||||
def faker_hotel(number):
|
||||
return response.succ(faker.faker_hotels(int(number)))
|
||||
|
||||
|
||||
@app.route("/faker/contacts/<num_hotel>/<num_railway>")
|
||||
def faker_contacts(num_hotel, num_railway):
|
||||
return response.succ(faker.faker_contacts(int(num_hotel), int(num_railway)))
|
||||
|
||||
|
||||
@app.route("/test")
|
||||
def test():
|
||||
print(
|
||||
select(Hotel.identification).
|
||||
join(Hotel, )
|
||||
)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run()
|
||||
|
||||
Reference in New Issue
Block a user