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 lapis = require("lapis")
|
||||||
local config = require("lapis.config").get()
|
local config = require("lapis.config").get()
|
||||||
local to_json = require("lapis.util").to_json
|
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 app = lapis.Application()
|
||||||
|
local models = require("models")
|
||||||
|
|
||||||
app:get("/", function()
|
|
||||||
|
app:get("/", function(self)
|
||||||
-- return "Welcome to Lapis " .. require("lapis.version")
|
-- return "Welcome to Lapis " .. require("lapis.version")
|
||||||
return config.greeting .. " from port " .. config.postgres.password
|
return config.greeting .. " from port " .. config.postgres.password
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
app:match("/station/", function(self)
|
app:match("/spl/:station", function(self)
|
||||||
-- print( to_json(self.params))
|
-- print( to_json(self.params))
|
||||||
|
|
||||||
-- artist=%a&
|
-- artist=%a&
|
||||||
@ -62,24 +60,42 @@ app:match("/station/", function(self)
|
|||||||
-- queries --
|
-- 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
|
local track = models.Tracks:find({ name = track_name })
|
||||||
-- print("new artist!")
|
if not track then
|
||||||
-- artist = models.Artists:create({
|
print("new track: " .. track_name)
|
||||||
-- name = artist_name
|
track = models.Tracks:create({
|
||||||
-- })
|
name = track_name,
|
||||||
-- else
|
unique_name = track_name:lower()
|
||||||
-- print("old artist.")
|
})
|
||||||
-- end
|
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)
|
end)
|
||||||
|
|
||||||
|
|||||||
@ -3,12 +3,14 @@ error_log stderr notice;
|
|||||||
daemon off;
|
daemon off;
|
||||||
pid logs/nginx.pid;
|
pid logs/nginx.pid;
|
||||||
|
|
||||||
|
|
||||||
events {
|
events {
|
||||||
worker_connections 1024;
|
worker_connections 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
http {
|
http {
|
||||||
include mime.types;
|
include mime.types;
|
||||||
|
resolver 127.0.0.11;
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen ${{PORT}};
|
listen ${{PORT}};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user