florimondmanca on pip
dependabot[bot] on npm_and_yarn
dependabot[bot] on npm_and_yarn
Bump acorn from 6.1.1 to 6.4.1 … (compare)
Good stuff @Marlysson! I think we could add this to a troubleshooting section in the FAQ.
Would you mind opening an issue with as many details as you can on the problem and your setup (OS, Python version before/after the fix, any tracebacks, etc)? It would be better than handling this via the chat.
If you know how to use Docker you can try to reproduce the issue in a Linux container, and post the Dockerfile so that we can see how/why this happens. Otherwise I can have a shoot at it myself. :)
createcommand, it should give you an example of a full-featured project file structure: https://github.com/bocadilloproject/bocadillo-cli
Hi Ilyes! Thanks for pitching in, this is an interesting question!
Actually, Bocadillo uses Starlette as an ASGI toolkit, not as a framework. For example, we reuse Starlette’s HTTP request representation (the Request class), as well as various ASGI middleware classes (eg the CORS middleware) and some other features (eg background tasks). But Bocadillo has a different design for views, and other features completely separate from Starlette (eg dependency injection). This hasn’t happened yet, but I’d be very much keen to bring generic enough features back into Starlette (in fact, I am personally a contributor to Starlette and uvicorn). :)
OTOH, it is true that FastAPI can be seen as a framework of a framework. For example, its app class is a direct subclass of ‘Starlette’ class. I think tiangolo is involved in both Starlette and uvicorn as well though.
+---demo ¦ +---demo ¦ ¦ +---app.py ¦ ¦ +---asgi.py ¦ ¦ +---providerconf.py ¦ ¦ +---settings.py ¦ ¦ +---__init__.py ¦ +---templates
(D:\SVNRepo\projects-sw\async_web\trunk\env) D:\SVNRepo\projects-sw\async_web\tr unk\env\projects\demo\demo>uvicorn asgi:app --reload INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) INFO: Started reloader process  Process SpawnProcess-1: Traceback (most recent call last): File "d:\svnrepo\projects-sw\async_web\trunk\env\lib\multiprocessing\process.p y", line 297, in _bootstrap self.run() File "d:\svnrepo\projects-sw\async_web\trunk\env\lib\multiprocessing\process.p y", line 99, in run self._target(*self._args, **self._kwargs) File "d:\svnrepo\projects-sw\async_web\trunk\env\lib\site-packages\uvicorn\mai n.py", line 305, in run loop.run_until_complete(self.serve(sockets=sockets)) File "d:\svnrepo\projects-sw\async_web\trunk\env\lib\asyncio\base_events.py", line 584, in run_until_complete return future.result() File "d:\svnrepo\projects-sw\async_web\trunk\env\lib\site-packages\uvicorn\mai n.py", line 312, in serve config.load() File "d:\svnrepo\projects-sw\async_web\trunk\env\lib\site-packages\uvicorn\con fig.py", line 182, in load self.loaded_app = import_from_string(self.app) File "d:\svnrepo\projects-sw\async_web\trunk\env\lib\site-packages\uvicorn\imp orter.py", line 23, in import_from_string raise exc from None File "d:\svnrepo\projects-sw\async_web\trunk\env\lib\site-packages\uvicorn\imp orter.py", line 20, in import_from_string module = importlib.import_module(module_str) File "d:\svnrepo\projects-sw\async_web\trunk\env\lib\importlib\__init__.py", l ine 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File ".\asgi.py", line 3, in <module> from .app import app ImportError: attempted relative import with no known parent package INFO: Stopping reloader process 
From the tutorial it seems like templates should be in the same subdirectory as app.py but jinja2 throws an error if it is
The docs say that it should be placed in the same directory relative to where the app is run (ie using uvicorn), so that means the location you put it at should work. Doesn’t it?
If I run uvicorn asgi:app --reload in the second demo subdirectory, it errors:
Yes, that is expected, because the generated demo package uses relative imports, which you can’t use in Python unless you’re running from outside of that package. We should probably add a warning/caveat in the docs