Difference between revisions of "Creating a Flask Web App"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Simple Method)
(Simple Method)
Line 10: Line 10:
  
 
[[File:Webapp.png]]
 
[[File:Webapp.png]]
 +
 +
Now open IDLE, and from the file menu select new file. Now type in the following code:
 +
 +
<syntaxhighlight =python>
 +
from flask import Flask
 +
 +
app = Flask(__name__)
 +
 +
@app.route("/")
 +
def hello():
 +
    return "Hello World!"
 +
 +
if __name__ == "__main__":
 +
    app.run()
 +
</syntaxhighlight>

Revision as of 12:30, 9 April 2019

Flask can be used to create a Web App, which can run from a server. You can obviously run this locally and use it as if it was fully live, this will allow you to develop the web app.

Setup

Simple Method

You will need to create a new folder for your web app:

Webapp1.png

Download this zip file and extract all of the contents to your new folder:

Webapp.png

Now open IDLE, and from the file menu select new file. Now type in the following code:

from flask import Flask

app = Flask(__name__)
 
@app.route("/")
def hello():
    return "Hello World!"
 
if __name__ == "__main__":
    app.run()