Skip to content

metmirr/simpleapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple REST API with falcon framework

A simple api, to demonstrate usage of falcon framework. It uses sqlite for database and sqlalchemy as orm.

Install Requirements

You can use virtualenv, pipenv or python builtin venv module to create an environmen. I will be using pipenv:

$ pipenv --python 3.7
$ pipenv shell && pipenv install

After requirements installation create a database file with command below:

$ python manage.py initdb

If you see this message You have database file in the current directoryto createad it run dropdb, initdb commands respectively. run python manage.py dropdb and python manage.py dropdb commands

Now you have a database and ready to use falcon api. Let`s run the server:

$ python manage.py runserver
 * Running on http://localhost:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 227-578-359

Methods:

$ sudo pip install httpie

Calling http methods:

get:

$ http localhost:5000/user username==foo email==foo@bar.com
HTTP/1.0 200 OK
content-length: 39
content-type: application/json; charset=UTF-8
{
    "email": "foo@bar",
    "username": "foo"
}

post:

$ http post localhost:5000/user username=foo email=foo@bar.com

delete:

$ http delete localhost:5000/user username==foo

About

A simple example to demonstrate api development with falcon

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages