getting somewhere
This commit is contained in:
parent
b53b91efc0
commit
4593c78532
58
code/app.lua
58
code/app.lua
@ -1,20 +1,18 @@
|
||||
local lapis = require("lapis")
|
||||
local config = require("lapis.config").get()
|
||||
local to_json = require("lapis.util").to_json
|
||||
local models = require("models")
|
||||
|
||||
-- print("models has type: " .. type(models))
|
||||
-- print(to_json(models))
|
||||
|
||||
local app = lapis.Application()
|
||||
local models = require("models")
|
||||
|
||||
app:get("/", function()
|
||||
|
||||
app:get("/", function(self)
|
||||
-- return "Welcome to Lapis " .. require("lapis.version")
|
||||
return config.greeting .. " from port " .. config.postgres.password
|
||||
|
||||
end)
|
||||
|
||||
app:match("/station/", function(self)
|
||||
app:match("/spl/:station", function(self)
|
||||
-- print( to_json(self.params))
|
||||
|
||||
-- artist=%a&
|
||||
@ -62,24 +60,42 @@ app:match("/station/", function(self)
|
||||
-- queries --
|
||||
-- ------- --
|
||||
|
||||
-- local artist = models.Artists:select("where name = ?", artist_name)
|
||||
local artist = models.Artists:find({ name = artist_name })
|
||||
if not artist then
|
||||
print("new artist: " .. artist_name)
|
||||
artist = models.Artists:create({
|
||||
name = artist_name
|
||||
})
|
||||
else
|
||||
print("old artist.")
|
||||
end
|
||||
|
||||
-- if not artist then
|
||||
-- print("new artist!")
|
||||
-- artist = models.Artists:create({
|
||||
-- name = artist_name
|
||||
-- })
|
||||
-- else
|
||||
-- print("old artist.")
|
||||
-- end
|
||||
local track = models.Tracks:find({ name = track_name })
|
||||
if not track then
|
||||
print("new track: " .. track_name)
|
||||
track = models.Tracks:create({
|
||||
name = track_name,
|
||||
unique_name = track_name:lower()
|
||||
})
|
||||
else
|
||||
print("old track.")
|
||||
end
|
||||
|
||||
-- local track = models.Tracks:select("where name = ?", track_name)
|
||||
local station = models.Stations:find({ station = self.params.station })
|
||||
if not station then
|
||||
print("unknown station: " .. self.params.station)
|
||||
else
|
||||
print("This is: " .. station["name"])
|
||||
end
|
||||
|
||||
-- airtime
|
||||
|
||||
-- local airtime = models.Airtimes:create({
|
||||
-- airtime = airtime_stamp,
|
||||
-- tracks = track,
|
||||
-- stations = station
|
||||
-- })
|
||||
|
||||
-- if track == nil then
|
||||
-- track = models.Tracks:create({
|
||||
-- name = track_name
|
||||
-- })
|
||||
-- end
|
||||
|
||||
end)
|
||||
|
||||
|
||||
@ -3,12 +3,14 @@ error_log stderr notice;
|
||||
daemon off;
|
||||
pid logs/nginx.pid;
|
||||
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include mime.types;
|
||||
resolver 127.0.0.11;
|
||||
|
||||
server {
|
||||
listen ${{PORT}};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user