from quart_openapi import Pint, Resource from quart import jsonify, request app = Pint(__name__, title='Spectacular Hypercorn Quart Application Skeleton') expected = app.create_validator('sample_request', { 'type': 'object', 'properties': { 'foobar': { 'type': 'string' }, 'baz': { 'oneOf': [ { 'type': 'integer' }, { 'type': 'number', 'format': 'float' } ] } } }) @app.route('/') class Root(Resource): async def get(self): '''Note Route This docstring will show up as the description and short-description for the openapi docs for this route. ''' return jsonify({"Note": "There exists a localhost:9000/openapi.json that can be helpful here"}) @app.expect(expected) async def post(self):
app.config["STOCKS_FOLDER"] = os.path.join(app.static_folder, "stocks") blueprint.stocks_folder = os.path.join(app.static_folder, "stocks") app.register_blueprint(blueprint) @app.route("/", methods=["GET", "POST"], provide_automatic_options=False) class Root(Resource): async def get(self): return await render_template("index.html") status_expected_schema = app.create_validator("status", { "type": "object", "properties": { "status": { "type": "string", }, }, }) @app.route("/status") class Status(Resource): @app.response( HTTPStatus.OK, description="A status of ok is system is up.", validator=status_expected_schema, ) async def get(self): return jsonify({"status": "ok"})
@app.route('/') class Root(Resource): async def get(self): '''Telegram API handler using Telethon Hello it is working''' return {"message": "hello"} sendCodeValidate = app.create_validator( 'sendCode', { 'type': 'object', 'properties': { 'phone_number': { 'type': 'string', 'description': 'Number to send code' } } }) @app.route('/isAuthorized') class isAuth(Resource): # @crossdomain('http://localhost:8080', credentials=True) # @route_cors( # # allow_headers=["content-type"], # # allow_methods=["POST"], # allow_origin=["http://127.0.0.1:*"], # allow_credentials=True # )