mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Handle table names with slashes in them
e.g. https://datasette-wdlexdiaoz.now.sh/fivethirtyeight-75d605c/bob-ross%2Felements-by-episode.csv?CABIN=1&BUSHES=1&CLOUDS=1
This commit is contained in:
parent
4c66097d58
commit
26370b14d8
8 changed files with 98 additions and 33 deletions
|
|
@ -119,18 +119,26 @@ def path_with_ext(request, ext):
|
|||
|
||||
|
||||
_css_re = re.compile(r'''['"\n\\]''')
|
||||
_boring_table_name_re = re.compile(r'^[a-zA-Z0-9_]+$')
|
||||
|
||||
|
||||
def escape_css_string(s):
|
||||
return _css_re.sub(lambda m: '\\{:X}'.format(ord(m.group())), s)
|
||||
|
||||
|
||||
def escape_sqlite_table_name(s):
|
||||
if _boring_table_name_re.match(s):
|
||||
return s
|
||||
else:
|
||||
return '[{}]'.format(s)
|
||||
|
||||
|
||||
def make_dockerfile(files):
|
||||
return '''
|
||||
FROM python:3
|
||||
COPY . /app
|
||||
WORKDIR /app
|
||||
RUN pip install https://static.simonwillison.net/static/2017/datasette-0.2-py3-none-any.whl
|
||||
RUN pip install https://static.simonwillison.net/static/2017/datasette-0.4-py3-none-any.whl
|
||||
RUN datasette build_metadata {} --metadata metadata.json
|
||||
EXPOSE 8006
|
||||
CMD ["datasette", "serve", {}, "--port", "8006", "--metadata", "metadata.json"]'''.format(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue