Code Monkey home page Code Monkey logo

web-applications-with-fastapi-course's Introduction

Web Applications with FastAPI course

Demo code and other handouts for students of our FastAPI Web Apps course.

Course Summary

FastAPI has burst on to the Python web scene. In fact, the 2020 PSF developer survey shows FastAPI going from off the radar to the 3rd most popular and fastest growing framework for Python developers. People discovering FastAPI are thrilled with it's toolchain for building APIs. But they wonder if they will need to build a parallel app in Flask or Django for the HTML side of their site.

This course is here to show you that you do not need a second browser-oriented framework: FastAPI is a fantastic framework for HTML-oriented content and static content. That's what this course is all about. You'll learn to build full web apps with FastAPI, equivalent to what you can do with Flask or Django. And it's an amazing framework with even more features than those older, more established frameworks.

What's this course about and how is it different?

There are not many courses out focusing on the FastAPI web framework. But even those that are around focus almost entirely on the API side of FastAPI. While that is useful and interesting, you'll need to answer the question of whether you need another web framework such as Flask or Django for the web browsers. The answer is no.

FastAPI is a truly modern framework that allows you to write web apps with dynamic HTML templates just as much as Flask. Throughout this course, you'll see how to use the various features of FastAPI along with a couple external packages to create wonderful Python web apps.

As part of the course, we well create a nearly complete clone of pypi.org in FastAPI. We'll learn how to use SQLAlchemy, HTML templates, static files, and even deploy our app to a Linux VM in the cloud.

What topics are covered

This course covers everything you need to know to develop, run, and deploy full web apps on top of FastAPI. Just some of the topics include:

  • Building a basic FastAPI application
  • Using server-side dynamic HTML templates such as Jinja2 and Chameleon
  • Centralizing look & feel as well as structural items with a layout HTML template
  • Serving static files from FastAPI (such as images and CSS files)
  • Using the view model design pattern to help with data exchange in FastAPI
  • Create HTML forms accepting user input and doing validation
  • Storing data in the SQLAlchemy ORM
  • Leveraging SQLAlchemy's new async/await capable API for scaling out
  • Deploy your FastAPI app to a Linux cloud VM

Course revisions

See the course revisions and change log.

Take the course

Take the course over at Talk Python Training today.

web-applications-with-fastapi-course's People

Contributors

mikeckennedy avatar mtgeekman 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

web-applications-with-fastapi-course's Issues

Testing

How do you write Unit tests for the database, when you define it this way?

pysqlite3 doesn't support asyncio

It seems the latest sqlalchemy beta release now does as better check for sqlite async support (or you have a different version of sqlite). I'm using python 3.8 and when I get to Chapter 8 I get the following error message after adding create_async_engine, etc.

sqlalchemy.exc.InvalidRequestError: The asyncio extension requires an async driver to be used. The loaded 'pysqlite' is not async.

Last login

Hello!

Where is proper place to specify logic for last login?
Is it some service put_last_login_by_user_id(user_id) which is called in LoginViewModel or something else?

Thank you

Basic App Output

Hi Mike,

Not sure why but the output I'm getting from the basic app does not display the JSON, Raw Data, etc. fastAPI tabs at the top of the browser window like your example shows.

Do you know why that might be?

Mine:
Screen Shot 2021-03-10 at 21 17 31

Yours:
Screen Shot 2021-03-10 at 21 16 43

Thanks
Michael

aiofiles not needed as a requirement

In Chapter 4, Static files, you show a ModuleNotFoundError: No module named 'aiofiles' error when mounting static files with app.mount('/static', StaticFiles(directory='static'), name='static')

I'm not getting that error and when I run pip list I'm not seeing aiofiles listed. Do you think Starlette updated StaticFiles to use something else?

Modifying .pt files and having Uvicorn reload

Hi Michael,

Great presentation! I was wondering if it is possible to have Uvicorn reload when you make changes to the templates just like it does when you make changes to the .py files?

Thanks in advanced!

Error in engine.py, using python3.9 (posixpath.py) when template_path is None

Hello, got this error trying to run using ch5-viewmodels from TalkPython Course... template_path is None.

I believe the problem is that fastapi_chameleon.global_init() is called after from fastapi_chameleon import template in home.py

Exception has occurred: TypeError       (note: full exception trace is shown but execution is paused at: _run_module_as_main)
expected str, bytes or os.PathLike object, not NoneType
  File "/home/cristiana/anaconda3/envs/fastapi/lib/python3.9/posixpath.py", line 76, in join
    a = os.fspath(a)
  File "/home/cristiana/anaconda3/envs/fastapi/lib/python3.9/site-packages/fastapi_chameleon/engine.py", line 72, in response_inner
    if not os.path.exists(os.path.join(template_path, template_file)):
  File "/home/cristiana/AAA-wip/Cursos-Programming/Curso-TalkPython-FastAPI-FullWeb/web-applications-with-fastapi-cris/views/home.py", line 13, in <module>
    def index(request: Request):
  File "/home/cristiana/AAA-wip/Cursos-Programming/Curso-TalkPython-FastAPI-FullWeb/web-applications-with-fastapi-cris/main.py", line 7, in <module>
    from views import home
  File "/home/cristiana/anaconda3/envs/fastapi/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/cristiana/anaconda3/envs/fastapi/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/home/cristiana/anaconda3/envs/fastapi/lib/python3.9/runpy.py", line 268, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/home/cristiana/anaconda3/envs/fastapi/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/cristiana/anaconda3/envs/fastapi/lib/python3.9/runpy.py", line 197, in _run_module_as_main (Current frame)
    return _run_code(code, main_globals, None,

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.