Skip to content
Snippets Groups Projects
Select Git revision
  • 11afdd6efd404a2c0e262d2c82751cc76f4299d9
  • master default
  • clement
  • fix_requirements
  • new_signup
  • interface_admin
  • hamza
  • dev
  • test
  • melissa
  • context_sheet
  • sorties_new
  • Seon82-patch-2
  • export_bdd
  • refactor/participation-user-link
15 results

factory.py

Blame
    • Seon82's avatar
      54c4c0e8
      Inscription sur le site (#21) · 54c4c0e8
      Seon82 authored
      
      * Password reset feature (#8)
      
      * Add Django Rest auth module
      
      * Try to make the send reset password email work
      
      * Modified template mail for reset
      
      * Add Django Rest auth module
      
      * Try to make the send reset password email work
      
      * Modified template mail for reset
      
      * test
      
      * Ajouté API student
      
      * API GET sans authentification
      
      * Added POST support
      
      * POST API fix
      
      * Fixed charfields length in wiki
      
      * loosen security
      
      * simplify API serialized data
      
      * Implemented partial_update
      
      * Added special teaching and nationality to serializer
      
      * dependantsNumber to int
      
      * Fixed factory imports
      
      * Added write auth and minor serializer fix
      
      * Added read permissions
      
      * Read permissions that work?
      
      * Actually added read permissions?
      
      * Updated tests to pass travis
      
      * Updated tests
      
      * Fixed all factory tests
      
      * Adapté les tests à la nouvelle structure de Student
      
      * Created StaffUserFactory and finished fixing tests
      
      * Update README.md
      
      * Added classType
      
      * Fixed migrations
      
      * Added last modified year & filters in admin interface
      
      Co-authored-by: default avatarchiahetcho <44137047+chiahetcho@users.noreply.github.com>
      Co-authored-by: default avatarflorimondmanca <florimond.manca@gmail.com>
      Co-authored-by: default avatarDylan Sechet <dylan.sechet@student-cs.fr>
      Co-authored-by: default avatarArthur Guédon <arthur.guedon@student-cs.fr>
      Inscription sur le site (#21)
      Seon82 authored
      
      * Password reset feature (#8)
      
      * Add Django Rest auth module
      
      * Try to make the send reset password email work
      
      * Modified template mail for reset
      
      * Add Django Rest auth module
      
      * Try to make the send reset password email work
      
      * Modified template mail for reset
      
      * test
      
      * Ajouté API student
      
      * API GET sans authentification
      
      * Added POST support
      
      * POST API fix
      
      * Fixed charfields length in wiki
      
      * loosen security
      
      * simplify API serialized data
      
      * Implemented partial_update
      
      * Added special teaching and nationality to serializer
      
      * dependantsNumber to int
      
      * Fixed factory imports
      
      * Added write auth and minor serializer fix
      
      * Added read permissions
      
      * Read permissions that work?
      
      * Actually added read permissions?
      
      * Updated tests to pass travis
      
      * Updated tests
      
      * Fixed all factory tests
      
      * Adapté les tests à la nouvelle structure de Student
      
      * Created StaffUserFactory and finished fixing tests
      
      * Update README.md
      
      * Added classType
      
      * Fixed migrations
      
      * Added last modified year & filters in admin interface
      
      Co-authored-by: default avatarchiahetcho <44137047+chiahetcho@users.noreply.github.com>
      Co-authored-by: default avatarflorimondmanca <florimond.manca@gmail.com>
      Co-authored-by: default avatarDylan Sechet <dylan.sechet@student-cs.fr>
      Co-authored-by: default avatarArthur Guédon <arthur.guedon@student-cs.fr>
    server.py 804 B
    """
    Server module for the web calculator.
    """
    from fastapi import FastAPI
    from fastapi.requests import Request
    from fastapi.templating import Jinja2Templates
    from calculator.calculator import Calculator
    
    app = FastAPI()
    templates = Jinja2Templates(directory="templates")
    calc = Calculator()
    
    @app.get("/")
    async def root(request: Request):
        """
        Default and only route of the web calculator.
        Expects either no query parameters or a single query parameter named "expression".
        """
        expression = request.query_params.get("expression", "")
        context = {"request": request}
        if expression:
            result = calc(expression)
            context = {"request": request,
                       "expression": expression, "result": result}
        return templates.TemplateResponse("index.html", context)