al-baba / codespace_application_testing

application within my personal 'ownership' for personal codespaces use. can fork from here.
0 stars 0 forks source link

representations #29

Open al-baba opened 3 weeks ago

al-baba commented 3 weeks ago

https://app.codecov.io/gh/openvar/rest_variantValidator/blob/development4/rest_VariantValidator%2Fendpoints%2Fhello.py

return representations.application_json({ return representations.xml({

@api.route("/")
class HelloClass(Resource):

    # Add documentation about the parser
    @api.expect(parser, validate=True)
    def get(self):

        vval = VariantValidator.Validator()

        # Collect Arguments
        args = parser.parse_args()
        config_dict = vval.my_config()
        config_dict['vvseqrepo_db'] = config_dict['vvseqrepo_db'].split('/')[-2]

        # Overrides the default response route so that the standard HTML URL can return any specified format
        if args['content-type'] == 'application/json':
            # example: http://127.0.0.1:5000/name/name/bob?content-type=application/json
            return representations.application_json({                                                                          ###  here
                "status": "hello_world",
                "metadata": config_dict
            },
                200, None)
        # example: http://127.0.0.1:5000/name/name/bob?content-type=text/xml
        elif args['content-type'] == 'text/xml':
            return representations.xml({                                                                                             ### here
                 "status": "hello_world",
                 "metadata": config_dict
            },
                200, None)
        else:
            # Return the api default output
            return {
                 "status": "hello_world",
                 "metadata": config_dict
            }