[英]Best way to deploy with Flask android and website
I have 2 flask applications one for site and one for android.The first application rendering templates and the second return json on every request.I am about to deploy and i am wondering what's the best option.I 've made a little research and i have some options: 我有2个flask应用程序,一个用于站点,一个用于android。第一个应用程序渲染模板,第二个在每个请求上返回json。我将要部署,我想知道最好的选择是什么。我进行了一些研究,我有一些选择:
deploy 2 apps in different servers 在不同的服务器上部署2个应用
deploy 2 apps in same server in different virtual enviroments 在不同虚拟环境中的同一服务器上部署2个应用程序
convert 2 apps in one and deploy them using blueprints. 将2个应用程序合二为一,并使用蓝图进行部署。
I think that the first option is the worst.So i don't know if it's better idea to have 2 apps running in the same server with a domain and a subdomain like myapp.com and android.myapp.com or convert the into one and deploy it as it is. 我认为第一种选择是最糟糕的。所以我不知道让2个应用程序在同一个服务器上运行一个域和一个子域(例如myapp.com和android.myapp.com)是否更好,或者将其转换为一个更好的主意并按原样部署它。 I am using blueprints and i try to find something like blueprints of blueprints so i can use a main blueprint "site" with it's children blueprints and a second blueprint "android" with it's children blueprints but i didn't find something.
我正在使用蓝图,因此我尝试找到类似蓝图的蓝图,以便可以将主要蓝图“站点”与其子级蓝图一起使用,并将第二蓝图“ android”与其子级蓝图一起使用,但是我没有找到任何东西。 I need a little help because it's the first time i am deploying and i am a little confusing.Thank you!
我需要一点帮助,因为这是我第一次进行部署,我有些困惑。谢谢!
There are a few ways to go around this: 有几种解决方法:
Move all your APIs to some other route, say /mobile/<route>
and modify your android application to follow the /mobile
API. 将您所有的API移至其他路由,例如
/mobile/<route>
并修改您的android应用程序以遵循/mobile
API。
Get the user-agent from the request headers and then return your response accordingly : 从请求标头中获取用户代理,然后相应地返回响应:
from flask import request request.headers.get('User-Agent')
Alternatively, use the request.user_agents
string to get more information about the device which is requesting the data. 或者,使用
request.user_agents
字符串获取有关正在请求数据的设备的更多信息。
Personally, I would recommend using the /mobile
route for deploying it. 就个人而言,我建议使用
/mobile
路由进行部署。 But it is really up to you. 但这确实取决于您。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.