BicaVM/webserver/app.py

46 lines
1.1 KiB
Python
Raw Normal View History

2011-07-01 22:28:15 +01:00
#! /usr/bin/python
# -*- Mode: Python -*-
# -*- coding: UTF-8 -*-
# Copyright (C) 2009 by Artur Ventura
#
# File: app.py
# Time-stamp: Sun Aug 9 16:30:18 2009
#
# Author: Artur Ventura
#
import web
import commands
urls = (
'/(.*)', 'index',
)
app = web.application(urls, globals())
class index:
def GET(self,filename):
if filename.endswith("favicon.ico"):
web.webapi.notfound()
return ""
if filename == "jvm.js":
2011-07-04 18:20:27 +01:00
web.header('Content-Type', 'text/javascript')
return commands.getstatusoutput("cat ../src/*.js | cpp -DDEBUG -DDEBUG_INTRP -I../src/ -P -undef -CC -Wundef -std=c99 -nostdinc -Wtrigraphs -fdollars-in-identifiers")[1]
2011-07-04 18:20:27 +01:00
if "testRuntime" in filename:
alphex = filename[filename.rfind("/") + 1:];
2011-08-22 18:57:00 +01:00
return file("../runtime/" + alphex.replace(".","/") + ".class").read();
2011-07-01 22:28:15 +01:00
if filename == "":
return file("index.html").read()
try:
return file(filename).read()
except:
web.webapi.notfound()
return ""
if __name__ == "__main__":
app.run()