Book Image

Building web applications with Python and Neo4j

By : Sumit Gupta
Book Image

Building web applications with Python and Neo4j

By: Sumit Gupta

Overview of this book

Table of Contents (14 chapters)
Building Web Applications with Python and Neo4j
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Setting up web applications with Flask and Flask-RESTful


In this section, we will talk about the basics of developing web applications using Flask and Flask-RESTful.

Your first Flask application

As we discussed earlier, Flask is simple and straightforward. There are no complex rules or steps for developing web applications in Flask.

Perform the following steps to create your first web application using Flask:

  1. Create a module and name it FlaskWebApp.py.

  2. Edit FlaskWebApp.py and add the following code:

    from flask import Flask
    webapp = Flask(__name__)
    
    @webapp.route("/")
    def hello():
        return " Hello World!"
    
    if __name__ == '__main__':
        webapp.run(host='0.0.0.0',port=8999,debug=True)
  3. Next, open your console or command prompt and execute py FlaskWebApp.py. You will see something like the next screenshot:

And we are done!!!

Your first application is up and running on port 8999.

Next, you can open your web browser and type http://localhost:8999 in the URL navigation bar. You will see "Hello World!"...