Week 7— Running FLASK
Spotting Errors Before Uploading Your Project
--
Alright. Before actually uploading our projects on the server, let us check whether the server is properly working given the current setting. That is, would we be able to access the website from the browser now?
Running a FLASK Server
Let us create a basic FLASK server file:
from flask import Flask
app = Flask(__name__) @app.route('/')
def home():
return 'This is Home!' if __name__ == '__main__':
app.run('0.0.0.0', port=5000, debug=True)
Upload this file through FileZilla and run:
python app.py
This should result in an error indicating there is no flask package installed. Well, follow these steps below:
Installing FLASK Package through PIP
pip install flask
Running the FLASK Server Again
Use this command to run the server again:
python app.py
If successful, access the browser from Chrome:
http://[EC2 IP Address]:5000/
GUESS WHAT
This shouldn’t work. Why?
We’ll figure it out in the next story!!
Fin.