简体   繁体   English

基于Flask-RESTful的应用程序的实际部署

[英]Real life deployment of Flask-RESTful based app

I am a Python web development newbie trying to learn. 我是一名尝试学习Python网络开发新手。 I have a working simple app based on ExtJS (static) code making requests to the Flask-RESTful service. 我有一个基于ExtJS(静态)代码的工作简单应用程序,向Flask-RESTful服务发出请求。 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. 正如我提到的,从命令行运行Flask-RESTful时,它可以按预期工作。 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. 我真正不清楚的是什么,我无法找到一个很好的示例,说明如何将其部署到生产中,在该生产中,HTTP服务器在端口80(Apache?)上提供静态文件,但是仍然可以运行在某些服务器上运行的REST服务。其他港口。

Just to make things clear in the app ExtJS code issues AJAX calls to exchange JSON data with Flask-RESTful service. 只是为了使应用程序中的事情变得清晰,ExtJS代码会发出AJAX调用,以与Flask-RESTful服务交换JSON数据。 There's no markup that is generated by Python code (no templates) Python代码没有生成标记(没有模板)

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? 我应该取消捆绑ExtJS代码,将其部署到Apache并使其调用运行在Tornado之类的同一个盒子上的Flask-RESTful吗? Thanks in advance. 提前致谢。

Since your client is pure HTML, it can be done either way. 由于您的客户端是纯HTML,因此可以通过任何一种方式完成。 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. 然后使用主机名或端口进行标识。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM