Flask example with POST

Before actually answering your question: Parameters in a URL (e.g. key=listOfUsers/user1) are GET parameters and you shouldn’t be using them for POST requests. A quick explanation of the difference between GET and POST can be found here. In your case, to make use of REST principles, you should probably have: Then, on each URL, you can define the behaviour of different … Read more

Flask raises TemplateNotFound error even though template file exists

You must create your template files in the correct location; in the templates subdirectory next to the python module (== the module where you create your Flask app). The error indicates that there is no home.html file in the templates/ directory. Make sure you created that directory in the same directory as your python module, and that you did in fact … Read more

ImportError: No Module Named bs4 (BeautifulSoup)

Activate the virtualenv, and then install BeautifulSoup4: When you installed bs4 with easy_install, you installed it system-wide. So your system python can import it, but not your virtualenv python. If you do not need bs4 to be installed in your system python path, uninstall it and keep it in your virtualenv. For more information about virtualenvs, read this

Flask ImportError: No Module Named Flask

Try deleting the virtualenv you created. Then create a new virtualenv with: Then: Now let’s activate the virtualenv Now you should see (flask) on the left of the command line. Edit: In windows there is no “source” that’s a linux thing, instead execute the activate.bat file, here I do it using Powershell: PS C:\DEV\aProject> & .\Flask\Scripts\activate) Let’s install … Read more

Flask ImportError: No Module Named Flask

Try deleting the virtualenv you created. Then create a new virtualenv with: Then: Now let’s activate the virtualenv Now you should see (flask) on the left of the command line. Edit: In windows there is no “source” that’s a linux thing, instead execute the activate.bat file, here I do it using Powershell: PS C:\DEV\aProject> & .\Flask\Scripts\activate) Let’s install … Read more

Flask ImportError: No Module Named Flask

Try deleting the virtualenv you created. Then create a new virtualenv with: Then: Now let’s activate the virtualenv Now you should see (flask) on the left of the command line. Edit: In windows there is no “source” that’s a linux thing, instead execute the activate.bat file, here I do it using Powershell: PS C:\DEV\aProject> & .\Flask\Scripts\activate) Let’s install … Read more

Flask Template Not found

By default, Flask looks in the templates folder in the root level of your app. http://flask.pocoo.org/docs/0.10/api/ template_folder – the folder that contains the templates that should be used by the application. Defaults to ‘templates’ folder in the root path of the application. So you have some options, rename template to templates supply a template_folder param to have your template folder recognised by the flask … Read more