I am new to python and hence falcon. I started developing a RESTful API and falcon so far is great for it. There is some other requirement to serve a static web page and I dont want to write an app or spawn a server for that.
Is it possible from the falcon app to serve the static web page?
You can better control the routes to your static file like this:
import falcon
class StaticResource(object):
    def on_get(self, req, resp, filename):
        # do some sanity check on the filename
        resp.status = falcon.HTTP_200
        resp.content_type = 'appropriate/content-type'
        with open(filename, 'r') as f:
            resp.body = f.read()
app = falcon.API()
app.add_route('/static/{filename}', StaticResource())
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With