I have this simple flask application that I want to deploy. I want to use my own computer as the application’s server and I want to give it a domain name. Please give me step by step instructions on how to do that:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def home():
return "hello world"
if __name__ == "__main__":
app.run(host='0.0.0.0', port=50100, debug=True)
I tried to search for solutions on the internet and the flask documentation, but I could not find anything useful.
Willem is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
4
You can’t add domain to flask using app.run(host='mydomain.org')
because that’s not how it works. The host
parameter will only accept IP Address / Hostname of your device based on the documentation
So what you need to do you need to run flask on a single IP, and then map it to a domain.
If you’re the only one that wants to access Flask using the domain you can map in locally by adding an entry on hosts
file on your device which located at:
- Windows:
C:WindowsSystem32driversetchosts
- Linux:
/etc/hosts
If you want everybody to access Flask by using a domain, you need to map it (on the local area network – local DNS server or on a public DNS if your app is available publicly)