--Assuming that Python has already been installed last time
Terminal
#To home directory
$$ cd
#Create a Python virtual environment(myenv can be another name)
$$ python3 -m venv myenv
#Enable the Python virtual environment
$$ source myenv/bin/activate
#In the place of the environment name on the left(myenv)Is displayed, it is successful
#Keep pip up to date
$$ pip install --upgrade pip
#Install Flask
$$ pip install flask
#Check if there is a module in pip properly
$$ pip freeze
Terminal
#Create a py file, this time it will run on Apache/var/www/Make in html
$$ vi /var/www/html/test.py
test.py
#I say it many times'i'Input mode, when input is finished'esc'、':wq'End of saving with
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello World!'
if __name__ == '__main__':
#Flask is hosted by'0.0.0.0'It seems that it will not work otherwise, this area is essential
app.run(host='0.0.0.0')
Terminal
#Run in browser!
$$ python3 /var/www/html/test.py
# http://Public IP address set in AWS:Hello with connection to 5000!Should be doing
#End of Python virtual environment
$$ deactivate
――FLask worked for the time being! ――It was a long way ――After that, if you do your best to connect to MySQL from Python --Book Chan! --Bridge too far
Recommended Posts