-
-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Render Template #339
Comments
You should be insert a default get router before the template render:
|
@Paroxyste , can you please tell me how are you running your code and what is your directory structure? |
@shaohaiyang , this shouldn't be the case. Does it not work without a default route for you?
|
@Paroxyste , I think I might know your issue. Can you please try running it at a port different from Lmk if that works and then I might be able to come up with an explanation. |
1 similar comment
@Paroxyste , I think I might know your issue. Can you please try running it at a port different from Lmk if that works and then I might be able to come up with an explanation. |
@Paroxyste , this is a bit strange as I copied everything from your code and It is working for me. Which version of Robyn are you using? |
Can you please share your |
main.py # -----------------------------------------------------------------------------
# !/usr/bin/python3
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
from pathlib import Path
from robyn import Robyn
from robyn.templating import JinjaTemplate
import os
# -----------------------------------------------------------------------------
# APP: APP CONFIG
# -----------------------------------------------------------------------------
current_file_path = Path(__file__).parent.resolve()
JINJA_TEMPLATE = JinjaTemplate(os.path.join(current_file_path, "templates"))
app = Robyn(__file__)
@app.get("/")
@app.get("/template_render")
def template_render():
context = {
"framework": "Robyn",
"templating_engine": "Jinja2"
}
template = JINJA_TEMPLATE.render_template(template_name="test.html", **context)
return template
app.start(port=5001) |
@Paroxyste , can you try running this to see if that works for you
|
Yes that work fine thanks very much |
Reopening this means that we should return this header by default.
I will create a PR for this. |
For the jinja implementation would it be possible to add something to load the resources like Flask:
or Starlette :
or for a route:
Because currently using url_for makes the template crash and returns a 500 error ... Out put this point the integration of jinja works well good job ;) |
@Paroxyste , sure. I can have a look at this :D |
We are working on this issue but it looks like it's already solved. I tried to produce the issue and my browser shows no problem with or without |
This issue was solved but was kept open for Jinja template resource loading. Closing this. |
Hello to all,
I have installed Robyn, via pip under python 3.10.6 on Mac M1.
I wanted to test the render_template but I have a problem. I copied the code from the doc but it doesn't work.
Jinja does a good job of replacing the values (framework, templating_engine) but the rendering prints the html code in the browser (i use Brave Browser) ...
Do you have any idea where this is coming from?
Thanks
The text was updated successfully, but these errors were encountered: