from flask import Flask from flask_swagger_ui import get_swaggerui_blueprint app = Flask(__name__) SWAGGER_URL = '/api/docs' # URL for exposing Swagger UI (without trailing '/') API_URL = 'http://petstore.swagger.io/v2/swagger.json' # Our API url (can of course be a local resource) # Call factory function to create our blueprint swaggerui_blueprint = get_swaggerui_blueprint( SWAGGER_URL, # Swagger UI static files will be mapped to '{SWAGGER_URL}/dist/'m API_URL, config={ # Swagger UI config overrides 'app_name': "digiFi-Core" }, # oauth_config={ # OAuth config. See https://github.com/swagger-api/swagger-ui#oauth2-configuration . # 'clientId': "your-client-id", # 'clientSecret': "your-client-secret-if-required", # 'realm': "your-realms", # 'appName': "your-app-name", # 'scopeSeparator': " ", # 'additionalQueryStringParams': {'test': "hello"} # } ) app.register_blueprint(swaggerui_blueprint) @app.route('/') def hello(): return "Hello World!" @app.route('/salary/login', methods=["POST"]) def salary_login(): try: data = request.json if not data: return { "message": "Please provide user details", "data": None, "error": "Bad request" }, 400 # validate input username = data["username"] password = data["password"] if username == 'digifiuser' and password == 'digifipass' : return { "message": "Successfully Login", "data": [ {"uid":"425611f2-c692-4404-b93d-76ca7a5ce70","icon": "icon_user", "name": "Simulator User" , "status": '1', "id": 1} ] }, 201 else: return { "message": "Error fetching auth token!, invalid email or password", "data": None, "error": "Unauthorized" }, 404 except Exception as e: return { "message": "Something went wrong!", "error": str(e), "data": None }, 500 @app.route('/salary/demousers') def salary_demousers(): return "Hello World!" if __name__ == '__main__': app.run(host='0.0.0.0', port=8000)