Giter Site home page Giter Site logo

tecladocode / rest-apis-flask-python Goto Github PK

View Code? Open in Web Editor NEW
1.3K 1.3K 1.5K 55.6 MB

Projects and e-book for our course, REST APIs with Flask and Python

Home Page: https://rest-apis-flask.teclado.com

Python 98.60% Dockerfile 0.78% Shell 0.18% Mako 0.43%
course education flask python udemy

rest-apis-flask-python's People

Contributors

andrew-harding-gh avatar antoniovmonge avatar cristianoyl avatar davimiku avatar dependabot[bot] avatar glmeece avatar jslvtr avatar justin-f-reeves avatar lukamilivojevic avatar lus24 avatar petarpetarpetar avatar pfabri avatar reillychase avatar sattamjh avatar senarclens avatar teclado-jennifer avatar teksaver avatar veeshostak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rest-apis-flask-python's Issues

circular dependency section 6

Hi,

In section 6 of your course, you spoke about circular dependency, but I don't understand why.
I try to put 'from db import db' at the top of the app.py file and it work without errors.

Could you explain brieffly, in which case this circular dependency happen ?

thanks,

Mickael

/auth error

in chapter 4 authentication and logging part2:
I got error when sending GET /auth

<!doctype html>
<html lang=en>
<title>405 Method Not Allowed</title>
<h1>Method Not Allowed</h1>
<p>The method is not allowed for the requested URL.</p>

UnitTests, JWT

Library flask_jwt is outdated. (Last commit was 3 years ago)

Item PUT HTTP response - correction proposal

def put(self, name):
data = Item.parser.parse_args()
item = ItemModel.find_by_name(name)
if item:
item.price = data['price']
else:
item = ItemModel(name, **data)
item.save_to_db()
return item.json()

Hi,
In Lec99, the HTTP response of PUT is not fully correctly dealt with. According to this: https://httpwg.org/specs/rfc7231.html, PUT should return 201, when new resource has been created.
(Also, added error handling similarly to the post() method)
So, I think implementation of put() should be appended with the HTTP response code handling, like this:

    def put(self, name):
        data = Item.parser.parse_args()
        item = ItemModel.find_by_name(name)

        # if item with name doesn't exist, we create it
        if item is None:
            item = ItemModel(name, **data)
            http_status_code = 200
        else:
            item.price = data["price"]
            http_status_code = 201

        try:
            item.save_to_db()
        except:
            return {"message": "An error occurred upserting the item."}, 500

        return item.json(), http_status_code

Best,
Csb

problems while doplying api in digital-ocean platform using mysql as database

in addition nginx in showed msg in the broswer 404 Not Found
i still google to fix them........and please if you add tut how to use MySQL instead of PostgreSQL but also you can help..thanks in advance sir Jose

*** Starting uWSGI 2.0.16 (64bit) on [Thu Feb 22 11:39:09 2018] ***
compiled with version: 5.4.0 20160609 on 22 February 2018 09:17:09
os: Linux-4.4.0-112-generic #135-Ubuntu SMP Fri Jan 19 11:48:36 UTC 2018
nodename: Flask-Api-Test
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /
detected binary path: /var/www/html/items-rest/venv/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
dropping root privileges as early as possible
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
your processes number limit is 3913
your memory page size is 4096 bytes
*** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers ***
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /var/www/html/items-rest/socket.sock fd 3
dropping root privileges after socket binding
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609]
Set PythonHome to /var/www/html/items-rest/venv
Python main interpreter initialized at 0x2066f80
dropping root privileges after plugin initialization
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 1315008 bytes (1284 KB) for 64 cores
*** Operational MODE: preforking+threaded ***
added /var/www/html/items-rest/ to pythonpath.

  • Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
  • Restarting with stat
    *** has_emperor mode detected (fd: 6) ***
    unable to load configuration from uwsgi

ch11 step 1 render.com does not create the tables

Running the app on render.com triggers the following

OperationalError
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: stores
[SQL: SELECT stores.id AS stores_id, stores.name AS stores_name
FROM stores]
(Background on this error at: https://sqlalche.me/e/20/e3q8)

Seems like the data.db is not created when running the app

500 error when creating new Item and no Store exists

When testing in Digital Ocean it showed a 500 error when I tried to create a new item with store id 1 without creating a store before sending the request.

Maybe it would be nice to check the existence of a store and show a more informative message.

Also, add to the course a note about this happening.

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.