Skip to content

Commit 8616a62

Browse files
author
Coderian
authored
Add files via upload
1 parent f2b69c6 commit 8616a62

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2755
-0
lines changed

versions/WARNING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**Please use the latest version for security and up-to-dateness; otherwise, we are not responsible for any issues you may encounter.**
2+
3+
**Thank you for your understanding💙.**

versions/v1.0/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 coderianx
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

versions/v1.0/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<p align="center">
2+
<img src="assets/flint.jpg" alt="Flint Logo" width="200"/>
3+
</p>
4+
5+
<h1 align="center">Flint</h1>
6+
<p align="center">A blazing fast and lightweight web framework for Go.</p>
7+
8+
[![Docs](https://img.shields.io/badge/Web_site-Flint-%23098687?style=for-the-badge&logo=firefox-browser&logoColor=white)](https://flintgo.netlify.app)
9+
10+
[![Telegram Channel](https://img.shields.io/badge/Telegram-Channel-blue?logo=telegram)](https://t.me/flint_framework)
11+
12+
[![Telegram Turkey Channel](https://img.shields.io/badge/Telegram-Channel_Türkiye-blue?logo=telegram)](https://t.me/flint_framework_tr)
13+
14+
[![X](https://img.shields.io/badge/X-Account-black?logo=twitter)](https://x.com/flintframework)
15+
16+
[![YouTube](https://img.shields.io/badge/YouTube-Channel-red?logo=youtube)](https://youtube.com/@flint_framework)
17+
18+
19+
---
20+
21+
## ⚡️ What is Flint?
22+
23+
Flint is a simple and minimal backend framework written in Go, made for fast API development with clean structure and easy usage.
24+
25+
## 🚀 Quick Start
26+
27+
```bash
28+
go get github.com/coderianx/Flint
29+
```
30+
31+
```go
32+
package main
33+
34+
import "github.com/coderianx/Flint"
35+
36+
func main() {
37+
app := flint.New()
38+
39+
app.Handle("/", func(c flint.Context) {
40+
ctx.String("Hello from Flint!")
41+
})
42+
43+
app.Listen(":8080")
44+
}
45+
```
46+
47+
---
48+
49+
> Built with ❤️ using Go

versions/v1.0/assets/flint.jpg

1.07 MB
Loading

versions/v1.0/assets/flint.png

1.31 MB
Loading

versions/v1.0/assets/flintlogo.png

1020 KB
Loading

versions/v1.0/assets/v1.0.png

852 KB
Loading

versions/v1.0/context.go

Lines changed: 307 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,307 @@
1+
package flint
2+
3+
import (
4+
"crypto/md5"
5+
"crypto/sha256"
6+
"crypto/sha512"
7+
"encoding/hex"
8+
"encoding/json"
9+
"html/template"
10+
"mime/multipart"
11+
"net/http"
12+
"strconv"
13+
"sync"
14+
15+
"golang.org/x/crypto/bcrypt"
16+
)
17+
18+
type Context struct {
19+
Writer http.ResponseWriter
20+
Request *http.Request
21+
}
22+
23+
func (c *Context) FormBcrypt(key string) string {
24+
password := c.FormData(key) // Formdan gelen veriyi al
25+
cost := 12
26+
hash, err := bcrypt.GenerateFromPassword([]byte(password), cost)
27+
if err != nil {
28+
LogError("FormBcrypt()", err.Error())
29+
return ""
30+
}
31+
return string(hash)
32+
}
33+
34+
func (c *Context) Redirect(status int, url string) {
35+
http.Redirect(c.Writer, c.Request, url, status)
36+
}
37+
38+
func (c *Context) FormFile(key string) (multipart.File, *multipart.FileHeader, error) {
39+
return c.Request.FormFile(key)
40+
}
41+
42+
func (c *Context) FormData(key string) string {
43+
return c.Request.FormValue(key)
44+
}
45+
46+
func (c *Context) FormInt(key string) int {
47+
val := c.FormData(key)
48+
num, err := strconv.Atoi(val)
49+
if err != nil {
50+
LogError("FormInt()", err.Error())
51+
return 0
52+
}
53+
return num
54+
}
55+
56+
func (c *Context) FormMD5(key string) string {
57+
hash := md5.Sum([]byte(c.FormData(key)))
58+
return hex.EncodeToString(hash[:])
59+
}
60+
61+
func (c *Context) FormSHA256(key string) string {
62+
hash := sha256.Sum256([]byte(c.FormData(key)))
63+
return hex.EncodeToString(hash[:])
64+
}
65+
66+
func (c *Context) FormSHA512(key string) string {
67+
hash := sha512.Sum512([]byte(c.FormData(key)))
68+
return hex.EncodeToString(hash[:])
69+
}
70+
71+
func (c *Context) Delete() bool {
72+
return c.Request.Method == http.MethodDelete
73+
}
74+
75+
func (c *Context) Post() bool {
76+
return c.Request.Method == http.MethodPost
77+
}
78+
79+
func (c *Context) Get() bool {
80+
return c.Request.Method == http.MethodGet
81+
}
82+
83+
func (c *Context) File(filepath string) {
84+
http.ServeFile(c.Writer, c.Request, filepath)
85+
}
86+
87+
func (c *Context) JSON(status int, data interface{}) {
88+
c.Writer.Header().Set("Content-Type", "application/json")
89+
c.Writer.WriteHeader(status)
90+
json.NewEncoder(c.Writer).Encode(data)
91+
}
92+
93+
func (c *Context) String(status int, text string) {
94+
c.Writer.Header().Set("Content-Type", "text/plain")
95+
c.Writer.WriteHeader(status)
96+
c.Writer.Write([]byte(text))
97+
}
98+
99+
// Template cache
100+
var tmplCache = make(map[string]*template.Template)
101+
var tmplLock sync.RWMutex
102+
103+
func (c *Context) HTML(status int, tmplPath string, data interface{}) {
104+
tmplLock.RLock()
105+
tmpl := tmplCache[tmplPath]
106+
tmplLock.RUnlock()
107+
108+
if tmpl == nil {
109+
t, err := template.ParseFiles(tmplPath)
110+
if err != nil {
111+
http.Error(c.Writer, err.Error(), 500)
112+
return
113+
}
114+
tmplLock.Lock()
115+
tmplCache[tmplPath] = t
116+
tmplLock.Unlock()
117+
tmpl = t
118+
}
119+
120+
c.Writer.Header().Set("Content-Type", "text/html")
121+
c.Writer.WriteHeader(status)
122+
tmpl.Execute(c.Writer, data)
123+
}
124+
125+
func (c *Context) Default404() {
126+
c.Writer.WriteHeader(http.StatusNotFound)
127+
c.Writer.Write([]byte(`
128+
<head>
129+
<meta charset="UTF-8">
130+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
131+
<title>Page Not Found - 404 Error Flint</title>
132+
<style>
133+
:root {
134+
--primary-color: #218c87;
135+
--primary-dark: #1a6f6b;
136+
--primary-light: #e8f4f3;
137+
--text-color: #333;
138+
--white: #ffffff;
139+
}
140+
141+
* {
142+
margin: 0;
143+
padding: 0;
144+
box-sizing: border-box;
145+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
146+
}
147+
148+
body {
149+
background-color: #f9f9f9;
150+
color: var(--text-color);
151+
display: flex;
152+
flex-direction: column;
153+
align-items: center;
154+
justify-content: center;
155+
height: 100vh;
156+
text-align: center;
157+
padding: 20px;
158+
}
159+
160+
.container {
161+
max-width: 600px;
162+
width: 100%;
163+
}
164+
165+
.error-image {
166+
width: 200px;
167+
height: 200px;
168+
margin-bottom: 30px;
169+
object-fit: contain;
170+
}
171+
172+
h1 {
173+
font-size: 5rem;
174+
color: var(--primary-color);
175+
margin-bottom: 20px;
176+
}
177+
178+
h2 {
179+
font-size: 1.8rem;
180+
margin-bottom: 15px;
181+
color: var(--text-color);
182+
}
183+
184+
p {
185+
font-size: 1.1rem;
186+
margin-bottom: 30px;
187+
line-height: 1.6;
188+
color: #666;
189+
}
190+
191+
.btn {
192+
display: inline-block;
193+
background-color: var(--primary-color);
194+
color: var(--white);
195+
padding: 12px 30px;
196+
border-radius: 50px;
197+
text-decoration: none;
198+
font-weight: 600;
199+
transition: all 0.3s ease;
200+
border: 2px solid var(--primary-color);
201+
margin: 0 10px;
202+
}
203+
204+
.btn:hover {
205+
background-color: var(--primary-dark);
206+
border-color: var(--primary-dark);
207+
transform: translateY(-2px);
208+
box-shadow: 0 5px 15px rgba(33, 140, 135, 0.3);
209+
}
210+
211+
.btn-outline {
212+
background-color: transparent;
213+
color: var(--primary-color);
214+
}
215+
216+
.btn-outline:hover {
217+
background-color: var(--primary-light);
218+
color: var(--primary-dark);
219+
}
220+
221+
.animation {
222+
animation: float 3s ease-in-out infinite;
223+
}
224+
225+
@keyframes float {
226+
0%, 100% {
227+
transform: translateY(0);
228+
}
229+
50% {
230+
transform: translateY(-15px);
231+
}
232+
}
233+
234+
@media (max-width: 768px) {
235+
h1 {
236+
font-size: 3.5rem;
237+
}
238+
239+
h2 {
240+
font-size: 1.4rem;
241+
}
242+
243+
.btn {
244+
display: block;
245+
margin: 10px auto;
246+
width: 80%;
247+
max-width: 250px;
248+
}
249+
}
250+
</style>
251+
</head>
252+
<body>
253+
<div class="container">
254+
<!-- Add your own image here -->
255+
<img src="assets/flint.jpg" alt="404 Error" class="error-image animation">
256+
257+
<h1>404</h1>
258+
<h2>Page Not Found</h2>
259+
<p>The page you are looking for might have been removed, had its name changed, or is temporarily unavailable. Please try to find what you need from our homepage.</p>
260+
261+
<div class="buttons">
262+
<a href="/" class="btn">Return to Homepage</a>
263+
<a href="https://t.me/Grayvort3x" class="btn btn-outline">Contact Support</a>
264+
</div>
265+
</div>
266+
267+
<script>
268+
// Simple animation effects
269+
document.addEventListener('DOMContentLoaded', function() {
270+
const image = document.querySelector('.error-image');
271+
272+
// Pause animation on hover
273+
image.addEventListener('mouseenter', function() {
274+
this.style.animationPlayState = 'paused';
275+
});
276+
277+
// Resume animation when mouse leaves
278+
image.addEventListener('mouseleave', function() {
279+
this.style.animationPlayState = 'running';
280+
});
281+
282+
// Button click effect
283+
const buttons = document.querySelectorAll('.btn');
284+
buttons.forEach(button => {
285+
button.addEventListener('click', function() {
286+
this.style.transform = 'scale(0.95)';
287+
setTimeout(() => {
288+
this.style.transform = 'scale(1)';
289+
}, 200);
290+
});
291+
});
292+
});
293+
</script>
294+
</body>
295+
</html>
296+
`))
297+
}
298+
299+
func (c *Context) Template404(templatePath string, data ...any) {
300+
var d any
301+
if len(data) > 0 {
302+
d = data[0]
303+
} else {
304+
d = map[string]any{}
305+
}
306+
c.HTML(http.StatusNotFound, templatePath, d)
307+
}

0 commit comments

Comments
 (0)