From flask import Flask,render_template.request Syntax error: Invalid Syntax

from flask import Flask,render_template.request
Syntax error: Invalid Syntax

1 Like

You can’t use from...import to import a dotted name.

There are many ways to get the effect you are trying for. Here is one:

from flask import Flask, render_template
request = render_template.request
1 Like

same error is getting

1 Like

You wrote:

from flask import Flask,render_template.request

Did you perhaps mean:

from flask import Flask,render_template,request

with a comma instead of a period?

Knowing that you’re using Flask, it looks like this is a typo. The way you’ve written it implies that request is contained in the render_template module, but that’s not the case. Both render_template and request are both top-level imports; you import them straight from flask.

The following would be equivalent:

from flask import Flask
from flask import render_template
from flask import request

And for this reason, the usual recommendation is to have your imports separated by spaces:

from flask import Flask, render_template, request

so that syntax errors become clearer.

1 Like