Giter Site home page Giter Site logo

ite-306-module-18-alcantara's Introduction

ITE-306-MODULE-18-Alcantara

Step 1: Install Flask

To Install Flask open CMD:

$ pip install Flask

Step 2: Testing

  • copy hello.py and save it in your selected python compiler and save the program into hello.py
from flask import Flask
from flask import jsonify
from flask import request
app = Flask(__name__)
empDB=[
{
'id':'101',
'name':'Dorry Britz',
'title':'Technical Leader'
},
{ 
'id':'102',
'name':'Barbie Gurl',
'title':'Software Engineer'
}
]

@app.route("/")
def hello():
    return "Hello World!"

@app.route('/empdb/employee/', methods=['GET'])
def getAllEmp():
    return jsonify({'emp':empDB})

@app.route('/empdb/employee/<empId>', methods=['GET'])
def getEmp(empId):
    usr = [ emp for emp in empDB if (emp['id']==empId)]
    return jsonify({'emp':usr})

if __name__ == '__main__':
    app.run()
  • open CMD and type the python (hello.py) file directory
C:\Users\Desktop>python C:\Users\Desktop\hello.py

The Output would be:

* Serving Flask app 'hello'
* Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on http://127.0.0.1:5000
Press CTRL+C to quit

After pasting the URL it should display:

Hello World!

TO DO:

What is the output if you open this URL while hello.py is running:

http://127.0.0.1:5000/empdb/employee/
http://127.0.0.1:5000/empdb/employee/101
http://127.0.0.1:5000/empdb/employee/103

On your command prompt press "CTRL=C" to end the process of hello.py. What is the output if you open this URL while hello.py is not running:

http://127.0.0.1:5000/empdb/employee/

If you find this repository helpful then don't forget to give a star ๐ŸŒŸ to this repository. :)

ite-306-module-18-alcantara's People

Contributors

jkalcntr avatar

Stargazers

Frederick John avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.