Skip to content

Commit

Permalink
jsp2
Browse files Browse the repository at this point in the history
  • Loading branch information
celiknedim committed Feb 9, 2024
1 parent 1782073 commit bea3732
Show file tree
Hide file tree
Showing 45 changed files with 2,541 additions and 6 deletions.
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Utiliser l'image de base Python 3.8 slim-buster
FROM python:3.8-slim-buster

# Définir le répertoire de travail à la racine du projet
WORKDIR /

# Copier le fichier requirements.txt à la racine du projet
COPY requirements.txt .

# Installer les dépendances Python spécifiées dans requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt

# Copier tous les fichiers du projet à la racine du conteneur
COPY . .

# Exposer le port 8000 pour permettre l'accès à votre application FastAPI
EXPOSE 8000

# Commande pour exécuter l'application FastAPI lorsque le conteneur démarre
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
Binary file modified __pycache__/main.cpython-312.pyc
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
23 changes: 17 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,28 @@
# import demo
# demo.test()


from fastapi import FastAPI
import uvicorn
from typing import Annotated
from fastapi import FastAPI, Request, Form
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates

app = FastAPI()

app.mount("/static", StaticFiles(directory="static"), name="static")
templates = Jinja2Templates(directory="templates")


@app.get("/")
def read_root():
return {"Hello": "World"}

if __name__ == "__main__":
uvicorn.run("main:app", host="localhost", port=8000, reload=True)
@app.get("/login")
def read_test(request:Request, x:str = None):
return templates.TemplateResponse(
request=request, name="login.html", context={"name": 'Nedim'}
)

@app.post("/login")
async def login(username: Annotated[str, Form()], password: Annotated[str, Form()]):
users=[{'user': 'admin'}, {'pwd':"1234"} ]
return {"username": username}
15 changes: 15 additions & 0 deletions main1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from typing import Union

from fastapi import FastAPI

app = FastAPI()


@app.get("/")
def read_root():
return {"Hello": "World"}


@app.get("/items/{item_id}")
def read_item(item_id: int, q: Union[str, None] = None):
return {"item_id": item_id, "q": q}
47 changes: 47 additions & 0 deletions myenv/Lib/site-packages/annotated-0.0.2.dist-info/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Annotated
=========
Annotated provides a decorator that flags a function's annotations as useful, callable expressions. Each annotation will be called with its corresponding argument as first parameter, and the result will replace that argument.

If no annotation was specified for this particular argument, it will behave as if `lambda x: x` had been used as annotation.

`@annotated` Decorator
----------------------
The `@annotated` decorator is meant to decorate functions, or other objects with a `__code__` attribute (a class is **not** one). It indicates that the function decorated has "active" annotations, for example:

```python
from annotated import annotated
@annotated
def hello(name: str):
print('Hello, ' + name + '!')
hello('world')
# "Hello, world!"
hello(None)
# "Hello, None!"
```

Albeit a bad example (one would rather use `str.format` or the `%` notation to include a value in a string), this illustrates the behaviour of an `@annotated` function.

Used this way, `@annotated` ensures that the `name` argument of the `hello` function is **always** a character string.

`@annotated` also respects default values, and applies annotations to them. Thus, if we were to rewrite `hello` such as:

```python
from annotated import annotated
@annotated
def hello(name: str='world'):
print('Hello, ' + name + '!')
hello()
# "Hello, world!"
```

The default value would be honored, as well as any non-defaults.

It should be noted that `@annotated` supports both return annotations (`->`), keyword argument annotations and `*`/`**` annotations.

Using `@annotated` on an incompatible (`__code__`-less) object will result in a `TypeError` exception.


Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pip
63 changes: 63 additions & 0 deletions myenv/Lib/site-packages/annotated-0.0.2.dist-info/METADATA
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
Metadata-Version: 2.0
Name: annotated
Version: 0.0.2
Summary: Apply annotations as callables on their respective arguments
Home-page: https://github.com/WhatNodyn/Annotate
Author: Neil Cecchini
Author-email: [email protected]
License: MIT
Keywords: annotations decorator function development
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: License :: OSI Approved :: MIT License

Annotated
=========
Annotated provides a decorator that flags a function's annotations as useful, callable expressions. Each annotation will be called with its corresponding argument as first parameter, and the result will replace that argument.

If no annotation was specified for this particular argument, it will behave as if `lambda x: x` had been used as annotation.

`@annotated` Decorator
----------------------
The `@annotated` decorator is meant to decorate functions, or other objects with a `__code__` attribute (a class is **not** one). It indicates that the function decorated has "active" annotations, for example:

```python
from annotated import annotated

@annotated
def hello(name: str):
print('Hello, ' + name + '!')

hello('world')
# "Hello, world!"
hello(None)
# "Hello, None!"
```

Albeit a bad example (one would rather use `str.format` or the `%` notation to include a value in a string), this illustrates the behaviour of an `@annotated` function.

Used this way, `@annotated` ensures that the `name` argument of the `hello` function is **always** a character string.

`@annotated` also respects default values, and applies annotations to them. Thus, if we were to rewrite `hello` such as:

```python
from annotated import annotated

@annotated
def hello(name: str='world'):
print('Hello, ' + name + '!')

hello()
# "Hello, world!"
```

The default value would be honored, as well as any non-defaults.

It should be noted that `@annotated` supports both return annotations (`->`), keyword argument annotations and `*`/`**` annotations.

Using `@annotated` on an incompatible (`__code__`-less) object will result in a `TypeError` exception.


12 changes: 12 additions & 0 deletions myenv/Lib/site-packages/annotated-0.0.2.dist-info/RECORD
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
annotated-0.0.2.dist-info/DESCRIPTION.rst,sha256=yhrULTMg59SMX4NfPhZp2mrESG8CqHTwREQzOTBb_9g,1675
annotated-0.0.2.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
annotated-0.0.2.dist-info/METADATA,sha256=bRdbw0i3_biRODVjVh9moEse4FCtSEhId1AWtLrqzCE,2242
annotated-0.0.2.dist-info/RECORD,,
annotated-0.0.2.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
annotated-0.0.2.dist-info/WHEEL,sha256=rNo05PbNqwnXiIHFsYm0m22u4Zm6YJtugFG2THx4w3g,92
annotated-0.0.2.dist-info/metadata.json,sha256=pfwLjELeKf22E7x1mpdnuItTvhUQGty-Mo9cN3Gn0vM,741
annotated-0.0.2.dist-info/top_level.txt,sha256=-3_AkgXYcs4iqvDQ9oH0a1Pc0VKdpCUnLOb9QCcm3WY,10
annotated/__init__.py,sha256=MHehvTQbtA-Rwvp5k-lY03E_TD0tmCWVm-xw5W5fhJQ,59
annotated/__pycache__/__init__.cpython-312.pyc,,
annotated/__pycache__/annotated.cpython-312.pyc,,
annotated/annotated.py,sha256=Kdqm0CcuJqvNSDZ51U7ZK_lkK6FRxqzkqaYnkaAZnhY,2879
Empty file.
5 changes: 5 additions & 0 deletions myenv/Lib/site-packages/annotated-0.0.2.dist-info/WHEEL
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Wheel-Version: 1.0
Generator: bdist_wheel (0.29.0)
Root-Is-Purelib: true
Tag: py3-none-any

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"classifiers": ["Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Topic :: Software Development :: Libraries", "Programming Language :: Python :: 3 :: Only", "License :: OSI Approved :: MIT License"], "extensions": {"python.details": {"contacts": [{"email": "[email protected]", "name": "Neil Cecchini", "role": "author"}], "document_names": {"description": "DESCRIPTION.rst"}, "project_urls": {"Home": "https://github.com/WhatNodyn/Annotate"}}}, "generator": "bdist_wheel (0.29.0)", "keywords": ["annotations", "decorator", "function", "development"], "license": "MIT", "metadata_version": "2.0", "name": "annotated", "summary": "Apply annotations as callables on their respective arguments", "version": "0.0.2"}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
annotated
3 changes: 3 additions & 0 deletions myenv/Lib/site-packages/annotated/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .annotated import annotated

__all__ = ('annotated',)
Binary file not shown.
Binary file not shown.
79 changes: 79 additions & 0 deletions myenv/Lib/site-packages/annotated/annotated.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import functools, inspect

def read_values(f):
"""Fetches information about arguments and annotations of a function.
Returns a dict containing the retrieved information
f -- The function to analyze, required
"""

# Fetch the code object, since it contains most of the values we use.
code = getattr(f, '__code__', None)
if not inspect.iscode(code):
t = getattr(type(f), '__name__', repr(type(f)))
raise TypeError("'{}' object does not have a code child".format(t))

# Fill the resulting dictionary.
d = {}

# These are the normal, non-variadic arguments.
d['args'] = code.co_varnames[:code.co_argcount]

# And these, the keyword-only arguments.
n = code.co_argcount + code.co_kwonlyargcount
d['keywords'] = code.co_varnames[code.co_argcount:n]

# These are the normal, variadic arguments (*args).
# Bitwise AND with 4 of the code.co_flags value checks for existence of a
# variadic argument receptacle, check the dis module for more information.
d['varargs'] = code.co_varnames[n] if code.co_flags & 4 else None

# These are the keyword variadic arguments (**kwargs).
# Same note as above, with 8, this time.
n += 1 if code.co_flags & 4 else 0
d['varkeywords'] = code.co_varnames[n] if code.co_flags & 8 else None

# The rest is pretty straightforward
d['defaults'] = f.__defaults__ or tuple()
d['keyword_defaults'] = f.__kwdefaults__ or {}
d['annotations'] = f.__annotations__ or {}

return d

def annotated(f):
"""Applies the decorated function's annotations to its arguments.
Returns a wrapper around the annotated function.
f -- The function to annotate, required
"""

fi = read_values(f)
a = lambda name, default=(lambda x: x): fi['annotations'].get(name, default)

@functools.wraps(f)
def _f(*args, **kwargs):
new_args = []

# First, we apply annotations to non-variadic, non-keyword arguments.
# We loop over registered arguments rather than existing ones to
# ensure defaults, among other things.
for i, arg in enumerate(fi['args']):
if i < len(args):
new_args.append(a(arg)(args[i]))
else:
new_args.append(a(arg)(fi['defaults'][len(args) - i]))

# Then we apply annotations to variadic, non-keyword arguments.
if fi['varargs'] is not None:
new_args.extend(map(a(fi['varargs']), args[len(fi['args']):]))

# Then we get a dictionary of all annotated default values.
new_keywords = {k: a(k)(v) for k, v in fi['keyword_defaults'].items()}
for k, v in kwargs.items():
nk = k if k in fi['keywords'] else fi['varkeywords']
print(k, nk)
new_keywords[k] = a(nk)(v)

return a('return')(f(*new_args, **new_keywords))

return _f
15 changes: 15 additions & 0 deletions myenv/Lib/site-packages/multipart/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This is the canonical package information.
__author__ = "Andrew Dunham"
__license__ = "Apache"
__copyright__ = "Copyright (c) 2012-2013, Andrew Dunham"
__version__ = "0.0.7"


from .multipart import (
FormParser,
MultipartParser,
OctetStreamParser,
QuerystringParser,
create_form_parser,
parse_form,
)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit bea3732

Please sign in to comment.