21
This commit is contained in:
7
.gitattributes
vendored
7
.gitattributes
vendored
@@ -1,7 +0,0 @@
|
|||||||
* text=auto eol=lf
|
|
||||||
*.bat eol=crlf
|
|
||||||
|
|
||||||
**/*.v linguist-language=V
|
|
||||||
**/*.vv linguist-language=V
|
|
||||||
**/*.vsh linguist-language=V
|
|
||||||
**/v.mod linguist-language=V
|
|
24
.gitignore
vendored
24
.gitignore
vendored
@@ -1,24 +0,0 @@
|
|||||||
# Binaries for programs and plugins
|
|
||||||
main
|
|
||||||
v5
|
|
||||||
*.exe
|
|
||||||
*.exe~
|
|
||||||
*.so
|
|
||||||
*.dylib
|
|
||||||
*.dll
|
|
||||||
|
|
||||||
# Ignore binary output folders
|
|
||||||
bin/
|
|
||||||
|
|
||||||
# Ignore common editor/system specific metadata
|
|
||||||
.DS_Store
|
|
||||||
.idea/
|
|
||||||
.vscode/
|
|
||||||
*.iml
|
|
||||||
|
|
||||||
# ENV
|
|
||||||
.env
|
|
||||||
|
|
||||||
# vweb and database
|
|
||||||
*.db
|
|
||||||
*.js
|
|
@@ -1,8 +0,0 @@
|
|||||||
module databases
|
|
||||||
|
|
||||||
import db.sqlite // can change to 'db.mysql', 'db.pg'
|
|
||||||
|
|
||||||
pub fn create_db_connection() !sqlite.DB {
|
|
||||||
mut db := sqlite.connect('app.db')!
|
|
||||||
return db
|
|
||||||
}
|
|
@@ -1,8 +0,0 @@
|
|||||||
module main
|
|
||||||
|
|
||||||
import vweb
|
|
||||||
|
|
||||||
@[post]
|
|
||||||
pub fn (mut app App) signup() vweb.Result{
|
|
||||||
return $vweb.html()
|
|
||||||
}
|
|
@@ -1,12 +0,0 @@
|
|||||||
module main
|
|
||||||
|
|
||||||
@[table: 'auth']
|
|
||||||
pub struct Auth {
|
|
||||||
mut:
|
|
||||||
id int @[primary; sql: serial]
|
|
||||||
username string @[sql_type: 'TEXT']
|
|
||||||
email string @[sql_type: 'TEXT'; unique]
|
|
||||||
access_level int @[sql_type: 'INTEGER']
|
|
||||||
password string @[sql_type: 'TEXT']
|
|
||||||
// products []Product @[fkey: 'user_id']
|
|
||||||
}
|
|
45
src/main.v
45
src/main.v
@@ -1,45 +0,0 @@
|
|||||||
module main
|
|
||||||
|
|
||||||
import vweb
|
|
||||||
import os
|
|
||||||
import databases
|
|
||||||
|
|
||||||
const (
|
|
||||||
port = 8082
|
|
||||||
)
|
|
||||||
|
|
||||||
struct App {
|
|
||||||
vweb.Context
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn (app App) before_request() {
|
|
||||||
println('[web] before_request: ${app.req.method} ${app.req.url}')
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
mut db := databases.create_db_connection() or { panic(err) }
|
|
||||||
|
|
||||||
sql db {
|
|
||||||
// create table Faculty (
|
|
||||||
// id serial primary key,
|
|
||||||
// name text not null,
|
|
||||||
// email text not null unique,
|
|
||||||
// password text not null
|
|
||||||
// )
|
|
||||||
create table Auth
|
|
||||||
} or { panic('error on create table: ${err}') }
|
|
||||||
|
|
||||||
db.close() or { panic(err) }
|
|
||||||
|
|
||||||
mut app := &App{}
|
|
||||||
app.serve_static('/favicon.ico', 'src/assets/favicon.ico')
|
|
||||||
// makes all static files available.
|
|
||||||
app.mount_static_folder_at(os.resource_abs_path('.'), '/')
|
|
||||||
|
|
||||||
vweb.run(app, port)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn (mut app App) login() vweb.Result {
|
|
||||||
|
|
||||||
return $vweb.html()
|
|
||||||
}
|
|
@@ -1,24 +0,0 @@
|
|||||||
<!-- Log-In Page -->
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Log In</title>
|
|
||||||
<!-- Add this line to include the Tailwind CSS library -->
|
|
||||||
@css 'https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css'
|
|
||||||
</head>
|
|
||||||
<body class="bg-gray-100 flex items-center justify-center min-h-screen">
|
|
||||||
<div class="w-full max-w-md">
|
|
||||||
<h1 class="text-3xl mb-6 font-bold text-center text-blue-500">Welcome Back!</h1>
|
|
||||||
<form action="/login" method="post">
|
|
||||||
<div class="mb-4">
|
|
||||||
<label for="email" class="block text-sm font-medium leading-relaxed tracking-wide mb-2">Email:</label>
|
|
||||||
<input type="email" id="email" name="email" placeholder="Enter email address" class="appearance-none bg-white rounded w-full py-2 px-4 leading-tight focus:outline-none focus:shadow-outline"/>
|
|
||||||
</div>
|
|
||||||
<div class="mb-4">
|
|
||||||
<label for="password" class="block text-sm font-medium leading-relaxed tracking-wide mb-2">Password:</label>
|
|
||||||
<input type="password" id="password" name="password" placeholder="Enter password" class="appearance-none bg-white rounded w-full py-2 px-4 leading-tight focus:outline-none focus:shadow-outline"/>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">Log In</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@@ -1,28 +0,0 @@
|
|||||||
<!-- Sign-Up Page -->
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Sign Up</title>
|
|
||||||
<!-- Add this line to include the Tailwind CSS library -->
|
|
||||||
@css 'https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css'
|
|
||||||
</head>
|
|
||||||
<body class="bg-gray-100 flex items-center justify-center min-h-screen">
|
|
||||||
<div class="w-full max-w-md">
|
|
||||||
<h1 class="text-3xl mb-6 font-bold text-center text-blue-500">Create an Account</h1>
|
|
||||||
<form action="/signup" method="post">
|
|
||||||
<div class="mb-4">
|
|
||||||
<label for="username" class="block text-sm font-medium leading-relaxed tracking-wide mb-2">Username:</label>
|
|
||||||
<input type="text" id="username" name="username" placeholder="Enter username" class="appearance-none bg-white rounded w-full py-2 px-4 leading-tight focus:outline-none focus:shadow-outline"/>
|
|
||||||
</div>
|
|
||||||
<div class="mb-4">
|
|
||||||
<label for="email" class="block text-sm font-medium leading-relaxed tracking-wide mb-2">Email:</label>
|
|
||||||
<input type="email" id="email" name="email" placeholder="Enter email address" class="appearance-none bg-white rounded w-full py-2 px-4 leading-tight focus:outline-none focus:shadow-outline"/>
|
|
||||||
</div>
|
|
||||||
<div class="mb-4">
|
|
||||||
<label for="password" class="block text-sm font-medium leading-relaxed tracking-wide mb-2">Password:</label>
|
|
||||||
<input type="password" id="password" name="password" placeholder="Enter password" class="appearance-none bg-white rounded w-full py-2 px-4 leading-tight focus:outline-none focus:shadow-outline"/>
|
|
||||||
</div>
|
|
||||||
<button type="submit" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline">Submit</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@@ -1,7 +0,0 @@
|
|||||||
module main
|
|
||||||
|
|
||||||
import vweb
|
|
||||||
|
|
||||||
pub fn (mut app App) signup() vweb.Result{
|
|
||||||
return $vweb.html()
|
|
||||||
}
|
|
Reference in New Issue
Block a user