mirror of
				https://github.com/StefBuwalda/WebTech.git
				synced 2025-10-31 11:49:58 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			27 lines
		
	
	
		
			840 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			840 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from flask_wtf import FlaskForm  # type: ignore
 | |
| from wtforms import StringField, SubmitField, URLField
 | |
| from wtforms.validators import DataRequired
 | |
| from flask_wtf.file import FileField, FileAllowed  # type: ignore
 | |
| 
 | |
| 
 | |
| # Form for service on dashboard, connected to database through ORM
 | |
| class ServiceForm(FlaskForm):
 | |
|     name = StringField(
 | |
|         "Service name:",
 | |
|         validators=[DataRequired()],
 | |
|         render_kw={"placeholder": "Service Name"},
 | |
|     )
 | |
|     url = URLField(
 | |
|         "Service URL:",
 | |
|         validators=[DataRequired()],
 | |
|         render_kw={"placeholder": "https://example.com"},
 | |
|     )
 | |
|     # File field that only allows jpg, jpeg or png
 | |
|     image = FileField(
 | |
|         "Icon:",
 | |
|         validators=[
 | |
|             FileAllowed(["jpg", "jpeg", "png"], "Unsupported file format"),
 | |
|         ],
 | |
|     )
 | |
|     submit = SubmitField("Submit")
 |