Search code examples
pythonrestextjsweb-deploymentflask-restful

Real life deployment of Flask-RESTful based app


I am a Python web development newbie trying to learn. I have a working simple app based on ExtJS (static) code making requests to the Flask-RESTful service. It has the following structure:

MyApp |
      | - client |
      |          | - app.html, //static stuff: html, css, js, images etc (all ExtJS)
      |
      | - server |
                 | - server.py, // Python code

As I mentioned it works as intended when running Flask-RESTful from command line. What is not really clear to me and I'm not able to find a good example on how to deploy this into production where static files served by HTTP server on port 80 (Apache?) but still able to hit REST service which runs on some other port.

Just to make things clear in the app ExtJS code issues AJAX calls to exchange JSON data with Flask-RESTful service. There's no markup that is generated by Python code (no templates)

Should I unbundle ExtJS code deploy it to Apache and make it to call Flask-RESTful that runs on the same box on something like Tornado? Thanks in advance.


Solution

  • Since your client is pure HTML, it can be done either way. I recommend separating them, though, since normally they are separated so you will learn it in a more realistic setup. You can use Apache for both by setting them up as virtual hosts. Then use either the host name or the port to identify them.