-
Notifications
You must be signed in to change notification settings - Fork 0
Application
The application is intended to have the following features :
- Homepage
- Authentication
- Posts
- Interactive map
The home page displays posts written by the user in a traditional blogging fashion.
From any pages, users can log in and log out.
Logging in, allows users to write new posts.
Posts can contain images of the places, the food, and geographical information allowing map display of the location.
The interactive map is another way to browse the articles.
The homepage displays the posts. It offers basic functionality with a navigation bar at the top.
You can access the homepage following the link :
https://strasbourg-resto-bistro.azurewebsites.net/

Posts can contain both text, images and locations.
The posts are managed in the module blog.py : https://github.com/AlainKa/srb/blob/main/blog.py
The view to display the posts is in index.html : https://github.com/AlainKa/srb/blob/main/templates/blog/index.html
The view for creation is in create.html : https://github.com/AlainKa/srb/blob/main/templates/blog/create.html
In blog.py see specifically the function for posts creation : create.
It uses flask request to get informations from the form contained in the view. See documentation for request https://tedboy.github.io/flask/generated/generated/flask.Request.html.
Within the request, the form part contains the title and body of the post. The files part of the request contains an image for the post.
The image is stored in the static folder of the app. It's name is stored in database alongside other post information for later retrieval.
WIP : When the user uploads an images, even before sending the form, there should be some kind of feedback to tell that the images has been successfully uploaded. Ideally, the image should be displayed in the post editor.
The flask documentation for image uploads seems to recommend the use of extensions, see docs. The use of extensions is motivated by the fact that the pattern for file uploads is often the same in every websites.
Flask WTF is such an extension that provides an integration of WTF forms for flask. Those forms are compatibles with multiple frameworks such as django and provide data validation, protections... It is more than enough for our needs so far.
Flask WTF documentation.
Examples from the internet :
To use wtf forms when writing the html file, instead of using html input elements, fields are created using flask templating. This has the upside of making the form easier to write on both ends.
The posts are displayed in the homepage of the website.
The backend is written in the get_post function in blog.py.
The function receives posts identifiers and fetches them from the database.
WIP : It should use the filename value to retrieve the static image and add it to the post displayed.