创建本地自定义主机名而不是localhost? [英] Creating a local custom host name instead of localhost?
问题描述
当前,我的烧瓶应用程序在以下位置本地运行:
Currently, my flask app runs locally on:
如何为我的应用创建本地自定义位置,如:
How could I create a local custom location for my app like:
排序类似于本地域名.这有可能吗?任何指针都很棒.
Sort of like a local domain name. Is this possible at all? Any pointers would be great.
推荐答案
In order for the browser to resolve this custom name, you will need to add an alias to your /etc/hosts file. It probably already contains a line about 127.0.0.1, in which case you just add your alias to the list
127.0.0.1 localhost localhost.localdomain myappname
然后您可以在应用程序的配置中更改服务器名称,以使其明确使用此名称.
You can then change the server name in the app's config to make it explicitly use this name.
app.config['SERVER_NAME'] = 'myappname:5000'
只有特权程序(以root或sudo身份运行)可以绑定到较低的端口(例如80),因此您仍然必须使用较高的端口号.
Only privileged programs (run as root or with sudo) can bind to low ports such as 80, so you will still have to use a high port number.
这篇关于创建本地自定义主机名而不是localhost?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!