Linux subdomain creation problem

Linux subdomain creation problem

Generalize

One day, when I was using my linux to debug a web page, I suddenly encountered such an error
code:

import flask
app = flask.Flask(__name__)
@app.route('/',subdomain='123')
def home_123():
    return 'hello world'
app.config['SERVER_NAME'] = 'test.com:5000'
app.run()

Error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/***马赛克***/anaconda3/lib/python3.7/site-packages/flask/app.py", line 943, in run
    run_simple(host, port, self, **options)
  File "/Users/***马赛克***/anaconda3/lib/python3.7/site-packages/werkzeug/serving.py", line 814, in run_simple
    inner()
  File "/Users/***马赛克***/anaconda3/lib/python3.7/site-packages/werkzeug/serving.py", line 774, in inner
    fd=fd)
  File "/Users/***马赛克***/anaconda3/lib/python3.7/site-packages/werkzeug/serving.py", line 660, in make_server
    passthrough_errors, ssl_context, fd=fd)
  File "/Users/***马赛克***/anaconda3/lib/python3.7/site-packages/werkzeug/serving.py", line 577, in __init__
    self.address_family), handler)
  File "/Users/***马赛克***/anaconda3/lib/python3.7/socketserver.py", line 452, in __init__
    self.server_bind()
  File "/Users/***马赛克***/anaconda3/lib/python3.7/http/server.py", line 137, in server_bind
    socketserver.TCPServer.server_bind(self)
  File "/Users/***马赛克***/anaconda3/lib/python3.7/socketserver.py", line 466, in server_bind
    self.socket.bind(self.server_address)
OSError: [Errno 49] Can't assign requested address

I immediately understood that my SERVER_NAME is "test.com:5000", but I did not match the domain name "test.com:5000" to the local.
Oh, yes, I have to match the domain name of 123.test.com:5000.
The following is the process

process

First, to configure the domain name, you need to modify "/etc/hosts" to
execute the command:

sudo vim /etc/hosts

After the following scene appears, enter the password (may not appear) After the
enter password
input is completed, the following scene appears:
vim scene
add as required, format:

127.0.0.1       <将此处替换成你需要的>

For example, what I need to add:

127.0.0.1       test.com
127.0.0.1       123.test.com

Result: At
After modification
this point, it is complete

Copyright Notice

The copyright belongs to the author of this article's reference and himself, please declare the source (if you are too lazy to write it, you don't see it, don't pursue it, you just know it)

Author

hit-road

Bye, get out of class is over!

Hit-road will be updated from time to time, see or leave!

Guess you like

Origin blog.csdn.net/weixin_42954615/article/details/108003240